Solve a differential system in one file

1 次查看(过去 30 天)
Hi i'm trying to solve this :
function dy = vdp1000(t,y)
dy = zeros(2,1); % a column vector
dy(1) = y(2);
dy(2) = 1000*(1 - y(1)^2)*y(2) - y(1);
end
[[T,Y]=ode15s(@vdp1000,[0 3000], [2 0]);
plot(T,Y(:,1),'-o')
but it does not work and i would like it work without command window but matlab answers me :
Error: File: vdp1000.m Line: 9 Column: 1 This statement is not inside any function. (It follows the END that terminates the definition of the function "vdp1000".)

回答(1 个)

Torsten
Torsten 2015-5-12
function driver
[T,Y]=ode15s(@vdp1000,[0 3000], [2 0]);
plot(T,Y(:,1),'-o')
function dy = vdp1000(t,y)
dy = zeros(2,1); % a column vector
dy(1) = y(2);
dy(2) = 1000*(1 - y(1)^2)*y(2) - y(1);
Best wishes
Torsten.
  1 个评论
abc abc
abc abc 2015-5-12
thank you for your answer but matlab answers me :
Warning: File: vdp1000.m Line: 4 Column: 15
Function with duplicate name "vdp1000" cannot be called.
Error using vdp1000
Too many input arguments.
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 148)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in vdp1000 (line 2)
[T,Y]=ode15s(@vdp1000,[0 3000], [2 0]);
it doesn't work :/

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by