How solve a ODE with ODE45

First I did my m.file
% creating the m file to solve the EDO
function wdot= EOM(t,o)
%%%%%o= omega
j1=6000; j2=3000; j3=3000;
y=40; z=40; alfa=0
area=40*40;
f=1.8*(100)*((cos(2*alfa)+1)/2)*area;
f1=1.8*(100)*((cos(2*alfa)+1)/2)*(area/2);
ycp=-f1*z/f; zcp=-f1*y/f;
t1=0 t2=f*ycp; t3=f*zcp;_
o=[w1;w2;w3]; MY VECTOR OMEGA
wdot=[((t1+(j2-j3)*w2*w3)/j1);((t2+(j3-j1)*w3*w1)/j2);((t3+(j1-j2)*w1*w2)/j3)]; end
WHEN I CALL MY ODE45, it keeps asking for w1 w2 w3, AND i wanted that the ODE45 solve this for me
[t,o]=ode45(@EOM,[0 100],[0,0,0]);

 Accepted Answer

Try this instead of your ‘o’ assignment:
w1 = o(1);
w2 = o(2);
w3 = o(3);
I would caution you about the variable names. The letter ‘o’ can be confused with the number 0 (and similarly the lower-case ‘l’ can be confused with ‘1’, especially if you are tired). (Personal experience.)

2 Comments

Thank you so much!!!!
As always, my pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!