Question: Problem 3 For an initial position ot 5.1 mm/s. For an initial position of 10.2 mm/s. There are several ways to use nested for loops

Problem 3 For an initial position ot 5.1 mm/s. For an initial position of 10.2 mm/s. There are several ways to use nested for loops for solving problems. This problem will use nested for loops to create plots of a spring-mass system with four different initial positions and three different initial velocity values. The result will be 12 different displacement traces. 37.8 mms 2.2 mmis -16.1 mm/s 37.8 mmMs 2.2 mmis 16.1 mms The equation for free vibration of an undamped spring-mass system is: 10 10 x(e) xcos(at) +sin(wt). -10 Here is the natural frequency, Xo the initial position, and Vo the initial velocity Create a MATLAB script with a set of nested for loops. The outer loop will run for the length of the initial position vector and the inner loop will run for the length of the initial velocity vector. For each of the four initial positions, create a new figure to plot all three displacement time traces with that same initial position but different initial velocities. The outer loop thus should contain figure, xlabel, ylabel, title, xlim, ylim, and hold on statements. The inner loop should contain the calculation of x(), aplot statement, and a pause statement. All four plots should have the same limits so that it is casy to 10 10 Time (s) For an initial position of 0.3 mm/s. Time (s) For an initial position of 24.8 mm/s. 37.8 mnVs 2.2 mm/s 16.1 mm/s 37.8 mm/ts 2 2 mm/s 16.1 mm/s 30 compare values across plots. 10 Recall from the class discussion that vectors can be used as loop variables, and incorporate this in your solution. 10 Use the following parameters: coo = 4.2; time[0:.01:10 xo= [5.1, 10.2, 24.8, 0.3]; Vo= [37.8, 2.2, 16.1); tmn % mm/s 10 10 Time (s) Time (s) See next page for expected results. Figure 2: Example output for problem 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
