Problem converting "suspn" model from Simulink to script - Results not matching
1 次查看(过去 30 天)
显示 更早的评论
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.
Here is the MATLAB example: http://www.mathworks.se/help/simulink/examples/automotive-suspension.html
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?
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multibody Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!