Borrar filtros
Borrar filtros

Solve a differential system in one file

2 visualizaciones (últimos 30 días)
abc abc
abc abc el 12 de Mayo de 2015
Comentada: abc abc el 12 de Mayo de 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".)

Respuestas (1)

Torsten
Torsten el 12 de Mayo de 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 comentario
abc abc
abc abc el 12 de Mayo de 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 :/

Iniciar sesión para comentar.

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by