ode 45 erroe undefined argument...

i get this error: Undefined function or variable 't'. for this code: function dy=doub(t,y) dy=zeros(4,1); dy(1)=y(2); dy(2)=(-0.1737*sin(y(1))-0.0579*sin(y(1)-2*y(3))-2*sin(y(1)-y(3))*16.4042*(y(4)^2-y(2)^2)*cos(y(1)-y(3))*0.0059)/(0.2905-9.6875*cos(2*y(1)-2*y(3))); dy(3)=y(4); dy(4)=(2*sin(y(1)-y(3))*(1.9375*Y(2)^2+0.1158*cos(y(1))+9.6875*10^2*y(4)^2*cos(y(1)-y(3))))/(0.2905-9.6875*cos(2*y(1)-2*y(3))); end and i cant find the reason... help me plz i need to find out why i get this error...

답변 (1개)

Star Strider
Star Strider 2016년 2월 27일

0 개 추천

Actually, it says Undefined function or variable 'T'. MATLAB is case-sensitive, so ‘T’ is not the same as ‘t’. The same goes for ‘y’ and ‘Y’.
This works:
Function —
function dy=doub(t,y)
dy=zeros(4,1);
dy(1)=y(2);
dy(2)=(-0.1737*sin(y(1))-0.0579*sin(y(1)-2*y(3))-2*sin(y(1)-y(3))*16.4042*(y(4)^2-y(2)^2)*cos(y(1)-y(3))*0.0059)/(0.2905-9.6875*cos(2*y(1)-2*y(3)));
dy(3)=y(4);
dy(4)=(2*sin(y(1)-y(3))*(1.9375*y(2)^2+0.1158*cos(y(1))+9.6875*10^2*y(4)^2*cos(y(1)-y(3))))/(0.2905-9.6875*cos(2*y(1)-2*y(3)));
end
Script —
[t,y]=ode45(@doub,[0 3000],[0 0 0 0]);
plot(t,y(:,1),'-',t,y(:,2),'-o',t,y(:,3),'-.',t,y(:,4),'.');

댓글 수: 4

sara rastakhiz
sara rastakhiz 2016년 2월 27일
thank u really!!! for answering my questions but the thing is...i tries what u said but again i get the same error...i no longer know what to do...again thank u
Star Strider
Star Strider 2016년 2월 27일
편집: Star Strider 2016년 2월 27일
As always, my pleasure!
Other than choosing different initial conditions, this works for me.
Function file —
function dy=doub(t,y)
dy=zeros(4,1);
dy(1)=y(2);
dy(2)=(-0.1737*sin(y(1))-0.0579*sin(y(1)-2*y(3))-2*sin(y(1)-y(3))*16.4042*(y(4)^2-y(2)^2)*cos(y(1)-y(3))*0.0059)/(0.2905-9.6875*cos(2*y(1)-2*y(3)));
dy(3)=y(4);
dy(4)=(2*sin(y(1)-y(3))*(1.9375*y(2)^2+0.1158*cos(y(1))+9.6875*10^2*y(4)^2*cos(y(1)-y(3))))/(0.2905-9.6875*cos(2*y(1)-2*y(3)));
end
Script file —
[t,y]=ode45(@doub,[0 3000],[0 0 0 0]);
plot(t,y(:,1),'-',t,y(:,2),'-o',t,y(:,3),'-.',t,y(:,4),'.');
This runs without error, although it’s unlikely to be interesting to any but those who enjoy watching paint dry, given the initial conditions provided.
Different initial conditions may make it more interesting.
What do you want it to do? What do we need to do to get it sorted?
sara rastakhiz
sara rastakhiz 2016년 2월 27일
편집: sara rastakhiz 2016년 2월 27일
i know it should work but...u see i tries the same example matlab gas provided in help but i got the same error...i guess there is a problem with my software...
its a project about towed systems i am analysing the cable and for starters i have divided it to tow parts and treated it like a double pendulum and when i get answers i will try the same this time with unlimited variables...
Star Strider
Star Strider 2016년 2월 27일
Did you use my code? It works, except that you will need different initial conditions to provide anything other than a zero output.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2016년 2월 27일

댓글:

2016년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by