2013-03-01 119 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