Problem converting "suspn" model from Simulink to script - Results not matching

조회 수: 3 (최근 30일)
Matt
Matt 2014년 11월 11일
답변: Matt 2014년 11월 12일
Hello,
I have tried to convert the existing MATLAB example available in Simulink called "sldemo_suspn", without success. I managed to have a running script, but the results given are different from those I get from Simulink.
For simplicity, in both the Simulink model and my script, I have removed the inputs so the system is only working to reach equilibrium. Here is my script:
Lf = 0.9;
Lr = 1.2;
Mb = 1200;
Iyy = 2100;
Kf = 28000;
Kr = 21000;
Cf = 2500;
Cr = 2000;
g=9.81;
timestep=0.01;
Mfront=0;
Mrear=0;
My=0;
Ffront=0;
Frear=0;
tetadot=0;
teta=0;
zdot=0;
z=0;
for(t=0:timestep:10)
tetadotdot=(My+Mfront+Mrear)/Iyy;
tetadot=tetadot+(tetadotdot*timestep);
teta=teta+(tetadot*timestep);
zdotdot=(Ffront+Frear-(Mb*g))/Mb;
zdot=zdot+(zdotdot*timestep);
z=z+(zdot*timestep);
Ffront=(2*Kf*(Lf*teta-z))+(2*Cf*(Lf*tetadot-zdot));
Frear=-(2*Kr*(Lr*teta+z))-(2*Cr*(Lr*tetadot-zdot));
Mfront=-Lf*Ffront;
Mrear=Lr*Frear;
t=t+timestep;
end
Here is the front force graph that I get from Simulink:
And the same but from my script file:
I am confused. Why are they not the same?

답변 (1개)

Matt
Matt 2014년 11월 12일
Bump, anyone spotting the problem?

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by