%Mason Averill %ME-544 Fall 2020, 10/5 %Special Problem 3 m=1000;%mass of car in kg kf=20*10^3;%spring constant of front shock in N/m kr=25*10^3;%spring constant of rear shock in N/m l1=1;%length from COG to front shock in m l2=1.5;%length from COG to rear shock in m IG=800;%Mass moment of inertia about the COG in kg*m^2 v=15;%velocity of vehicle in m/s d=10;%distance between wheels in m max_time=20;%max time period of interest in seconds step_size=0.001;%adjust this value to increase the resolution of the model, with a lower value indicating a higher resolution t=0:step_size:max_time; % time span of interest and fixed time step yf=.05*sin(2*pi()*v*t/d);%displacement function describing road for front shock yr=.05*sin(2*pi()*v*t/d-2*pi()*(l1+l2)/d);%displacement function describing road for rear shock initial_conditions=[0;0;0;0]; % initial condition for position and velocity, in x and theta A=[0 1 0 0;-(kf+kr)/m 0 -(kr*l2-kf*l1)/m 0;0 0 0 1; -(l2*kr-l1*kf)/IG 0 -(l1^2*kf+l2^2*kr)/IG 0]; % state matrix A B=[0 0 0 0;0 kr/m 0 kf/m; 0 0 0 0; 0 l2*kr/IG 0 -l1*kf/IG]; % input matrix B C=[1 0 0 0;0 1 0 0; 0 0 1 0; 0 0 0 1]; % output matrix C D=[0 0 0 0;0 0 0 0; 0 0 0 0; 0 0 0 0]; % direct transmission matrix D %populating the displacement matrix with values for the downward ground %displacemnt for the front and rear wheels for each increment in time %considered [a1,a2]=size(t); t(a2)=[]; u=zeros(4,a2-1); i=1; while(i