Question: Problem 7: Modify your Matlab code in Problem 5 to include input F(t). Simulate the system with these conditions: Initial conditions for stretch and velocity

 Problem 7: Modify your Matlab code in Problem 5 to includeinput F(t). Simulate the system with these conditions: Initial conditions for stretch

Problem 7: Modify your Matlab code in Problem 5 to include input F(t). Simulate the system with these conditions: Initial conditions for stretch and velocity are both 0. a. The force input is: F(t) = 1 + sin(2pi*t) b. The force input is: F(t) = cos(3pi*t) C. The force input is: F(t) = 2 (1 + sin(2pi*t)) + 3 cos(3pi*t) Plot the results for all 3 cases. Comment on how the results in case c. is related to results in cases a. and b.? [Hint:} How does it relate to "superposition" as discussed in lecture 2? Matlab code: % Sping- damper mass system clear all; cle; m = 1; % mass in kg b = 0.5 % damping constant in N/(m/s) k = 4 % sping constant in N/m Tfinal = 20; % final time in second dt = 0.1; % time step N = round(Tfinal/dt); % no. of time steps % initial condition x(1) = 1; % initial displacement x(2) = 1; % obtain from initial velocity is zero v(1) = 0; % initial velocity t(1) = 0; t(2) = dt; % coefficient A = (1/(dt*dt))+b/(m*dt); C = (2/(dt*dt))+b/(m*dt)-k/m; D = -1/(dt*dt); for i = 2: N x(i+1) = ( C*x(i) + D*x(i-1) )/A; t(i+1) = i*dt; v(i) = (x(i+1) - XO)/dt; end V(N+1) = V(N); subplot(2,1,1) plot(t,x,r,'Linewidth, 2) xlabel('Time(s)) ylabel('Displacement (m)) subplot(2,1,2) plot(t,v,'g'Linewidth, 2) xlabel('Time(s)) ylabel("Velocity (m/s)') Problem 7: Modify your Matlab code in Problem 5 to include input F(t). Simulate the system with these conditions: Initial conditions for stretch and velocity are both 0. a. The force input is: F(t) = 1 + sin(2pi*t) b. The force input is: F(t) = cos(3pi*t) C. The force input is: F(t) = 2 (1 + sin(2pi*t)) + 3 cos(3pi*t) Plot the results for all 3 cases. Comment on how the results in case c. is related to results in cases a. and b.? [Hint:} How does it relate to "superposition" as discussed in lecture 2? Matlab code: % Sping- damper mass system clear all; cle; m = 1; % mass in kg b = 0.5 % damping constant in N/(m/s) k = 4 % sping constant in N/m Tfinal = 20; % final time in second dt = 0.1; % time step N = round(Tfinal/dt); % no. of time steps % initial condition x(1) = 1; % initial displacement x(2) = 1; % obtain from initial velocity is zero v(1) = 0; % initial velocity t(1) = 0; t(2) = dt; % coefficient A = (1/(dt*dt))+b/(m*dt); C = (2/(dt*dt))+b/(m*dt)-k/m; D = -1/(dt*dt); for i = 2: N x(i+1) = ( C*x(i) + D*x(i-1) )/A; t(i+1) = i*dt; v(i) = (x(i+1) - XO)/dt; end V(N+1) = V(N); subplot(2,1,1) plot(t,x,r,'Linewidth, 2) xlabel('Time(s)) ylabel('Displacement (m)) subplot(2,1,2) plot(t,v,'g'Linewidth, 2) xlabel('Time(s)) ylabel("Velocity (m/s)')

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 Databases Questions!