how to get rid of error which says too many output arguments
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hi,
i want to solve the equation d^2x/dt^2= f(-2*x3 + x2) which is for 3 harmonic oscillators.In my editor i wrote the following;
function test3(t,x)
xdot(1)=x(2);
xdot(2)= 10*(-2*x3 + x2);
xdot=xdot';
end
and then i executed the command:
[t,x]=ode45('test3', [0 5], [2 3]);
and the error i get is " too many output arguments" which i don't know how to omit. How can i get rid of this error? Kindly if someone could help me figure it out i would be grateful. Thanks
0 Kommentare
Antworten (1)
Star Strider
am 10 Dez. 2019
The ‘test3’ function needs to be:
function xdot = test3(t,x)
xdot(1)=x(2);
xdot(2)= 10*(-2*x3 + x2);
xdot=xdot';
end
and the ode45 call needs to be:
[t,x]=ode45(@test3, [0 5], [2 3]);
That should work.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Scope Variables and Generate Names finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!