ode45 function Not enough input arguments error.
古いコメントを表示
Hello,
I copied a simple tutorial online on how to use an ode45 function. I have checked and double checked everything. I am going insane :) Any help would be greatly appreciated. I continuously receive the error:
*NOTE: I am a novice at MATLAB
if true
>> Animate
Error using Animate (line 5)
Not enough input arguments.
end
Here is my code:
if true
function xdot = Animate(t,x)
xdot = zeros(3,1);
xdot(1) = x(2) * x(3);
xdot(2) = -x(1) * x(3);
xdot(3) = -0.51 * x(1) * x(2);
[t,x] = ode45('Animate',[0 12], [0 1 1], options);
plot(t,x(:,1), '-',t,x(:,2),'-.',t,x(:,3),'.')
end
採用された回答
その他の回答 (2 件)
Azzi Abdelmalek
2013 年 10 月 2 日
1 投票
Your code is correct. Can you precise where is line 5
4 件のコメント
Susie
2013 年 10 月 2 日
Susie
2013 年 10 月 2 日
Azzi Abdelmalek
2013 年 10 月 2 日
Check if the right function Animate is in the current folder.
Susie
2013 年 10 月 2 日
Susie
2013 年 10 月 3 日
4 件のコメント
James Tursa
2013 年 10 月 3 日
I have a file called Animate.m in my current directory, which is:
function xdot = Animate(t,x)
xdot = zeros(3,1);
xdot(1) = x(2) * x(3);
xdot(2) = -x(1) * x(3);
xdot(3) = -0.51 * x(1) * x(2);
end
I then type in the following two lines at the command line (your options variable deleted from the call since you didn't specify what it was) and I get the plot:
[t,x] = ode45('Animate',[0 12], [0 1 1]);
plot(t,x(:,1), '-',t,x(:,2),'-.',t,x(:,3),'.')
Susie
2013 年 10 月 3 日
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
