2013-03-01 53 views
0

我按照上http://www.mit.edu/people/abbe/matlab/ode.html教程和如下製備的函數:Matlab的二階導數

function dxy = diffxy(xy) 
% 
%split xy into variables in our equations 
% 
x = xy(1); 
xdot = xy(2); 
y = xy(3); 
% 
% define the derivatives of these variables from equations 
% 
xdot = xdot; 
ydot = 3*x + 2*y + 5; 
xdoubledot = 3 - ydot + 2*xdot; 
% 
%return the derivatives in dxy in the right order 
% 
dxy = [xdot; xdoubledot; ydot] 
end 

當我打電話它使用

[T, XY] = ode45('diffxy',0,10,[0 1 0]) 

我得到一個錯誤

??? Error using ==> diffxy 
Too many input arguments. 
我也試過

XY = ODE45(@diffxy,[0 10],[0; 1; 0])

任何人有任何想法?

回答

3

沒有看過完整的教程,但你不應該定義功能

function dxy = diffxy(t, xy) 

其中t是時間向量

+0

尼斯和清潔THX。我新來這個東西... – dramaticlook 2013-03-01 13:35:44