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

18 ビュー (過去 30 日間)
naveed bashir
naveed bashir 2019 年 12 月 10 日
回答済み: Star Strider 2019 年 12 月 10 日
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

回答 (1 件)

Star Strider
Star Strider 2019 年 12 月 10 日
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.

カテゴリ

Help Center および File ExchangeScope Variables and Generate Names についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by