MATLAB Answers

how to get rid of error which says too many output arguments

3 views (last 30 days)
naveed bashir
naveed bashir on 10 Dec 2019
Answered: Star Strider on 10 Dec 2019
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 Comments

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 10 Dec 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 Comments

Sign in to comment.

Sign in to answer this question.