Problem converting "suspn" model from Simulink to script - Results not matching
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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:
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
And the same but from my script file:
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
I am confused. Why are they not the same?
0 comentarios
Respuestas (1)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!