plotting nonlinear system with constant input
Mostra commenti meno recenti
if I enter function in M-file like that:
function dx = suspension(t,x,Mb,Mf,Mr,I,Ksf,Ksr,Ktf,Ktr,Csf,Csr,Lf,Lr,Wf,Wr)
Mb=730;
Mf=40;
Mr=36;
I=1230;
Ksf=19960;
Ksr=17500;
Ktf=175500;
Ktr=175500;
Csf=1290;
Csr=1620;
Lf=1;
Lr=(1.8);
Wf=0.05;
Wr=0.05;
dx=zeros(8,1); %Wf and Wr is constant input as road bump
dx = [x(5);
x(6);
x(7);
x(8);
1/Mb*((-Ksf-Ksr)*x(1)+Ksf*x(2)+Ksr*x(3)-Lf*Ksf*sin(x(4))+Lr*Ksr*sin(x(4))-Lf*Csf*x(8)*cos(x(4))+Lr*Csr*x(8)*cos(x(4))-(Csf+Csr)*x(5)+Csf*x(6)+Csr*x(7));
1/Mf*(Ksf*x(1)-(Ksf+Ktf)*x(2)+Lf*Ksf*sin(x(4))+Lf*Csf*x(8)*cos(x(4))+Csf*x(5)-Csf*x(6)+Ktf*Wf);
1/Mr*(Ksr*x(1)-(Ksr+Ktr)*x(3)-Lr*Ksr*sin(x(4))-Lr*Csr*x(8)*cos(x(4))+Csr*x(5)-Csr*x(7)+Ktr*Wr);
1/I*((-Lf*Ksf+Lr*Ksr)*x(1)+Lf*Ksf*x(2)-Lr*Ksr*x(3)-Lf*Lf*Ksf*sin(x(4))-Lr*Lr*Ksr*sin(x(4))-Lf*Lf*Csf*x(8)*cos(x(4))-Lr*Lr*Csr*x(8)*cos(x(4))-(Lf*Ksf-Lr*Csr)*x(5)+Lf*Csf*x(6)-Lr*Csr*x(7))];
y=[x(2);x(3)];%output
end
>>[t,y]=ode45('suspension',[0 10],[0;0;0;0;0;0;0;0]);
>>plot(t,y(:,1));
what must I add in order to function running is true?
4 Commenti
the cyclist
il 3 Lug 2012
I was able to run your code without error. I don't understand the question you are asking. Are you able to write a little bit more explanation?
Eka
il 3 Lug 2012
Walter Roberson
il 3 Lug 2012
You are going to have to show us the .m file that is producing the error, and show us the error message you are getting.
Eka
il 5 Lug 2012
Risposte (1)
Walter Roberson
il 6 Lug 2012
0 voti
You are likely running into difficulty because you are using 'suspension' (the string) as the routine for ode45 to invoke, instead of using an anonymous function. When you use a string, the search path for the function is not the same as when you use an anonymous function.
Code using the anonymous function is shown in http://www.mathworks.com/matlabcentral/answers/42590-plotting-nonlinear-system-with-constant-input
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!