Solve a differential system in one file

7 views (last 30 days)
abc abc
abc abc on 12 May 2015
Commented: abc abc on 12 May 2015
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".)

Answers (1)

Torsten
Torsten on 12 May 2015
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 Comment
abc abc
abc abc on 12 May 2015
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 :/

Sign in to comment.

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!