필터 지우기
필터 지우기

Solve a differential system in one file

조회 수: 2 (최근 30일)
abc abc
abc abc 2015년 5월 12일
댓글: abc abc 2015년 5월 12일
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