m = 1000; % weight of the car t = 0:0.01:10; % defines a 10 s time interval with 10 ms spaced time points u = [zeros(1,100),ones(1,length(t)-100)]; % creates a 1 meter bump in the road % Simulation for Shock Absorber #1 - kd = 500 ks = 2000; kd = 500; % shock absorber #1 parameters a1 = kd/m; a0 = ks/m; b1 = kd/m; b0 = ks/m; % define the ODE coefficient arrays a = [1,a1,a0]; b= [b1,b0]; y1 = lsim(b,a,u,t); % performs the simulation % Simulation for Shock Absorber #2 - kd = 2000 ks = 2000; kd = 2000; % shock absorber #2 parameters a1 = kd/m; a0 = ks/m; b1 = kd/m; b0 = ks/m; % define the ODE coefficient arrays a = [1,a1,a0]; b= [b1,b0]; y2 = lsim(b,a,u,t); % performs the simulation % Plot the results plot(t,y1,'b-',t,y2,'r-', t, u, 'g-' ,'LineWidth',1.5); legend('Shock #1', 'Shock #2', 'Road '); xlabel('Time (s)'); ylabel('Height (m)'); figure(1);