Question: Can you write a matlab code for this?? The vertical position of a mass on a spring oscillates after being released if it is not

Can you write a matlab code for this?? The vertical position of a mass on a spring oscillates after being released if it is not initially at equilibrium, but the amplitude of the oscillation decreases exponentially (due to air resistance).
Assume that for a particular mass-spring system, the vertical position y of the mass follows y=e^-t cos(2pir), where t is time. In this case, the vertical velocity of the mass is v=-e^-t (2pisin(2pit)+cos(2pit)).
Write a MATLAB script in which you: Create a time vector t of equally spaced values between 0 and 5, in increments of 0.01.
Calculate the vertical position y for every time value.
Calculate the vertical velocity v for every time value.
On the left y-axis, plot the vertical position versus time.
Set the left y-axis limits to -1 and 1.
Label the left y-axis "y".
On the same figure, but on the right y-axis, plot the vertical velocity versus time.
Set the right y-axis limits to -6 and 6.
Label the right y-axis "v".
Label the x-axis "t".
Title the axes "Vertical position and velocity over time".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mechanical Engineering Questions!