Problem too many input arguments
이전 댓글 표시
Hi! We are having problems with ode45 this is our code:
xstart=xp; %start koordinaten i x-led
ystart=yp; %start koordinaten i y-led
xprimstart=xpprim;% Stoftsvansens starthastighet i x-led
yprimstart = ypprim;% Stoftsvansens starthastighet i y-led
tstart=0;
C=-1;
Clista = [C];
Xlista = [xstart];
Ylista =[ystart];
n=0; %vi tänker oss att vi beräknar kurvan för ca 30 partiklar
while n<20
tslut = 2989;
[t,U] = ode45(@(t,U) ekvationssystem_ode(t,U,C),[0 tslut],[xstart ystart xprimstart yprimstart]');
x = U(:, 1); % tar ut varje x-koordinat från U
y = U(:, 2);% tar ut varje y-koordinat från U
C = C+0.1;
Clista = [Clista,C]; %Lägger till varje nytt C värde i listan för C
Xlista = [Xlista,x]; %Lägger till varje nytt x värde i listan för X
Ylista = [Ylista,y]; %Lägger till varje nytt y värde i listan för Y
n=n+1;
end
This is our funktion we us in ode45
function uprim =ekvationssystem_ode(t,U,C) %funktion som löser vårt ekvationssystem
s=(U(1)^2 + U(2)^2)^0.5; %definition för s givet i uppgiften uprim =[U(3),U(4),(-C*U(1))/(s^3),(-C*U(2))/(s^3)]'; %vektorn uprim som ODE45 använder för att returnera vektorn U
these are our errors. ...
Error using ekvationssystem_ode Too many input arguments.
Error in @(t,U)ekvationssystem_ode(t,U,C)
Error in odearguments (line 87) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 113) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in mainprogram (line 68) [t,U] = ode45(@(t,U) ekvationssystem_ode(t,U,C),[0 tslut],[xstart ystart xprimstart yprimstart]');
Please help us! :)
댓글 수: 1
Adam
2014년 12월 4일
Have you tried isolating the problem and calling
@(t,U) ekvationssystem_ode(t,U,C)
with arguments:
[0 tslut]
and
[xstart ystart xprimstart yprimstart]'
outside of the ode45 function?
I can't see anything obviously wrong glancing at the code. I have never used ode45 so don't know anything about that, but it looks as though the error is independent of the use of the ode45 function and caused by your function handle passed to that.
답변 (1개)
Torsten
2014년 12월 4일
0 개 추천
Maybe you have to replace
[t,U] = ode45(@(t,U) ekvationssystem_ode(t,U,C),[0 tslut],[xstart ystart xprimstart yprimstart]');
by
[t,U] = ode45(@(t,y) ekvationssystem_ode(t,y,C),[0 tslut],[xstart ystart xprimstart yprimstart]);
and
uprim =[U(3),U(4),(-C*U(1))/(s^3),(-C*U(2))/(s^3)]';
by
uprim =[U(3);U(4);(-C*U(1))/(s^3);(-C*U(2))/(s^3)];
?
Best wishes
Torsten.
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!