0

我按照http://www.mit.edu/people/abbe/matlab/ode.html上的教程,准备了一个函数如下:

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])

有人知道吗?

4

1 回答 1

3

还没有阅读整个教程,但你不应该将你的函数定义为

function dxy = diffxy(t, xy)

t时间向量在哪里

于 2013-03-01T13:11:27.903 回答