plotting nonlinear system with constant input
이전 댓글 표시
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
the cyclist
2012년 7월 3일
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
2012년 7월 3일
Walter Roberson
2012년 7월 3일
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
2012년 7월 5일
답변 (1개)
Walter Roberson
2012년 7월 6일
0 개 추천
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
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!