Problem Set-1 c Week 11Challenge : Transient Handling
clear all
close all
clc
% Wheelbase (m)
l = 2.538984 ;
% cg to front axle (m)
a = 0.890016;
% cg to rear axle (m)
b = l-a;
% Mass (kg)
m = 907.18474;
% moment of inertia (kg-m^2)
jz = 1128 ;
% front cornering stiffness (N/rad)
cf = 61171.9437;
% rear cornering stiffness (N/rad)
cr = 50976.6191;
% Speed m/s
u = 100/3.6;
A=[-(cf+cr)/(m*u),(((b*cr)-(a*cf))/(m*u))-u;((b*cr)-(a*cf))/(jz*u),-((((a^2)*cf)+((b^2)*cr))/(jz*u))];
B=[cf/m;(a*cf)/jz];
% Lateral Speed
c1=[1,0];
d1=0;
%Yaw rate
c2=[0,1];
d2=0;
%lateral acceleration
c3=A(1,:)+u*[0,1];
d3=B(1);
t=[0:0.01:2];
st=(pi/180)*5*sin(2*pi*7*t);
C=[c1;c2;c3];
D=[d1;d2;d3];
sys=ss(A,B,C,D);
Y=lsim(sys,st,t);
sys.Inputname={'st'};
sys.Outputname={'lateral speed','yaw rate','lateral acceleration'};
[mag1,phase1,omega1] = bode(sys({'yaw rate'},{'st'}));
for i=1:length(mag1);
magnitude1(i)=mag1(1,1,i);
i=i+1;
end
figure(1)
loglog(omega1/(2*pi),magnitude1,'linewidth',2)
title('yaw gain frequency response')
grid on
figure(2)
subplot(2,2,1)
plot(t,st,'linewidth',2)
title('steering')
grid on
subplot(2,2,2)
plot(t,Y(:,1),'linewidth',2)
title('lateral speed')
grid on
subplot(2,2,3)
plot(t,Y(:,2),'linewidth',2)
title('yawrate')
grid on
subplot(2,2,4)
plot(t,Y(:,3),'linewidth',2)
title('lateral accelaration')
grid on
figure(3)
step(sys)
grid on
S=stepinfo(sys);
[wn theta]=damp(sys);
% front cornering stiffness (N/rad)
Cf = -61171.9437;
Cr = -50976.6191
YB=Cf+Cr;
YR=(a*Cf-b*Cr)/u;
YS=-Cf;
NB=a*Cf-b*Cr;
NR=(((a^2)*Cf)+((b^2)*Cr))/u;
NS=-a*Cf;
%UnDamped Natural Frequency
Wn=sqrt(((YB*NR)+(NB*m*u)-(YR*NB))/(m*u*jz))
�mping Ratio
Theta=abs(-((NR/jz)+(YB/(m*u)))*(1/(2*Wn)))
�mped Frequency
Wd=Wn*sqrt(1-(Theta)^2)
%Rise Time
tr=((m*u*NS)/((YS*NB)-(YB*NS)))