i have knowledge of programing in turbo pascal and a bit of c+ and i am having a bit of trouble with programming in matlab. I have a problem that i need to code in matlab and im struggling with it.
please can any1 help this is the problem:
For this problem you have been assigned a system of masses connected by springs with the parameters specified in the text file. In the diagram the bigger coloured circles are masses and are labelled with a number that is referenced in the text file. The smaller grey circles are stationary masses or pegs and do not move or need to have a mass associated with them. You must use this data to model the system of springs and masses given. You do not need to model friction or gravity the only forces being exerted in the system are by the springs. Using your model you will simulate the movement of all the masses from 0 to 100 seconds (including 100) with a time step of 0.1 seconds. Record the position of each mass (X and Y position) at every time step in an array. You will then plot the path of each mass in a different colour on a single plot with the X Axis to run from 0 to 10 meters and the Y axis from 0 to 7.5 meters. The plot must have properly labeled axes and a title. Your simulation must be written as a M-File script and must make use of at least one self-made function.
Physics Theory
To model the system of masses you will need to find the resultant force acting on each mass individually. This is done by evaluating how far each of the springs attached to a specific mass are stretched (euclidian distance between the two masses to which the spring is attached) and determining the angle at which the spring is pulling on the mass (must use atan2() function to do this as it takes the quadrants into aaccount). Then using the the following equation you can find the x-component and y-component forces that the spring is exerting on the mass.
where k is the spring constant and x is the displacement from the springs equilibrium point.
where Theta is the angle at which the spring is pulling.
You add up all the X component forces and Y component forces for a specific mass to find the result X and Y component force acting on that mass. Once you have the resultant force acting on a specific mass you can find its Acceleration from the following:
Fres = ma thus a = m/Fres
thus
thus
gives us our change in velocity and displacement for the mass. We must update the current velocity and displacement with these values to find the new position and speed of the mass at every time step. This must be done in the X and Y directions. is our chosen time step 0.1 seconds.
Do this process for every mass in your given system and you will have arrays of X and Y positions for each mass which you will then plot using the plot() function in MATLAB. Plot the first masses path then execute the Hold On command and plot the rest of the paths onto the same figure. To plot each path in a different colour you can just add a paramter to the plot function as follows plot(x,y,’r’); where the character r states the path must be red. You can use ‘g’,’b’,’y’ for green, blue and yellow. Please refer to the internet or MATLAB help if you need more colours.
Outputs
The following are the specific outputs expected from this assignment:
Represent the mass-spring system correctly in a model (each mass is connected correctly to the other masses using springs, keep track of all the parameters given to you)
Simulate the movement of the system for t = 0:0.1:100 seconds.
Calculate the position of each mass based on its resultant force for each time step
Plot the paths of each mass on a single plot in different colour.
The entire simulation must be written and run from an M-File/s.
Make use of at least one self-made function.
Mass M0 details:
Stationary mass, does not move
Starting Positions in meters:
X: 4
Y: 3.5
--------------------------------------…
Mass M1 details:
Mass 13.6 kg
Starting Positions in meters:
X: 3.84
Y: 2.84
--------------------------------------…
Mass M2 details:
Mass 16.4 kg
Starting Positions in meters:
X: 5.56
Y: 4.76
--------------------------------------…
Mass M3 details:
Mass 13.6 kg
Starting Positions in meters:
X: 4.08
Y: 4.12
--------------------------------------…
Mass M4 details:
Mass 12.6 kg
Starting Positions in meters:
X: 5.22
Y: 5.92
Spring S0 details:
K: 0.732
Equilibrium Distance (meters):
Eq: 0.86
--------------------------------------…
Spring S1 details:
K: 0.66
Equilibrium Distance (meters):
Eq: 1.64
--------------------------------------…
Spring S2 details:
K: 1.068
Equilibrium Distance (meters):
Eq: 1.34
--------------------------------------…
Spring S3 details:
K: 0.752
Equilibrium Distance (meters):
Eq: 0.96
--------------------------------------…
Spring S4 details:
K: 0.634
Equilibrium Distance (meters):
Eq: 0.76