필터 지우기
필터 지우기

Too many input arguments, which arguments should I remove?

조회 수: 1 (최근 30일)
Dursman Mchabe
Dursman Mchabe 2018년 10월 23일
댓글: Walter Roberson 2018년 10월 24일
Hi all, on the attached code, I am trying to use a for-loop and ode45 to solve odes and an algebraic equation in 31 iterations. However, I get an error message
Error using my_odesloop>odes
Too many input arguments.
Error in my_odesloop>@(t,y)odes(t,y,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) (line 46)
sol(j) = ode45(@(t,y) odes(t,y,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z),t,y0);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in my_odesloop (line 46)
sol(j) = ode45(@(t,y) odes(t,y,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z),t,y0);
I don't know which arguments to remove.
Please help.
  댓글 수: 2
KSSV
KSSV 2018년 10월 24일
YOur code is very buggy.......need lot's of changes.....what you are trying actually?
Dursman Mchabe
Dursman Mchabe 2018년 10월 24일
Thanks a lot for the response KSSV. I am trying to use a for-loop and ode45 to solve odes and an algebraic equation. The odes are in lines 60 to 82. The algebraic equation is nested in lines 49 to 51.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 10월 24일
Your function line for odes needs to list A, B, C, and so on.
  댓글 수: 3
Torsten
Torsten 2018년 10월 24일
Adopt the example "ODE with Time-Dependent Terms" under
https://de.mathworks.com/help/matlab/ref/ode45.html
to your case.
Best wishes
Torsten.
Walter Roberson
Walter Roberson 2018년 10월 24일
Guessing:
x0 = 9.46e-1;
xin = x0;
for j = 1:length(t)
sol(j) = ode45(@(t,y) odes(t,y,xin,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z),t,y0);
for i = 1:length(t)
x(i) = fsolve(@(x) x + 2.* e(j) - ((c(j).* A.*x)/(x.^2 + A.*x + A*B))- 2.*((c(j).*A*B)/(x.^2 ...
+ A.*x + A*B))-((d(j).*M.*x)/(x.^2 + M.*x + M*N))- 2.*((d(j).*M.*N)/(x.^2 ...
+ M.*x + M*N))- Y./x, x0);
end
plot(t,sol)
xin = x(j); %complete guess
end
end
function dydt = odes(t,y,x,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z)
a = y(1);
b = y(2);
c = y(3);
d = y(4);
e = y(5);
f = y(6);
g = y(7);
dydt = zeros(7,1);
dydt(1) = (1 /J).* (K.* L - K.* a ) - ((a.* E.* F - G.* ((c.* (x).^2)/((x).^2 + A.* (x) + A.* B))) / ( (1/H) + G/ ((1 + C.* e / (D.* c)).* I)));
dydt(2) = (1 /J).* (K .* R - K .* b) - (P .* (1 + C * e / (O .* d)) .* (b .* E .* F / Q - ((d.* (x(i)).^2)/((x).^2 + M.* (x) + M.* N))));
dydt(3) = ((a.* E.* F - G.* ((c.* (x).^2)/((x).^2 + A.* (x) + A.* B))) / ( (1/H) + G/ ((1 + C.* e / (D.* c)).* I))) - (Z .* 1.62e-3 .* exp(-5152 / F) .* ( (e .* ((c.* A .* B)/((x).^2 + A .* (x) + A .* B)) / S) - 1).^3 / T);
dydt(4) = (- U .* V .* W .* f .* (x) .* (1 - (X .* (x))/(1+ X .* (x)))) - (P .* (1 + C * e / (O .* d)) .* (b .* E .* F / Q - ((d.* (x).^2)/((x).^2 + M.* (x) + M.* N))));
dydt(5) = (- U .* V .* W .* f .* (x) .* (1 - (X .* (x))/(1+ X .* (x)))) - (Z .* 1.62e-3 .* exp(-5152 / F) .* ( (e .* ((c.* A .* B)/((x).^2 + A .* (x) + A .* B)) / S) - 1).^3 / T);
dydt(6) = (- U .* V .* W .* f .* (x) .* (1 - (X .* (x))/(1+ X .* (x))));
dydt(7) = (Z .* 1.62e-3 .* exp(-5152 / F) .* ( (e .* ((c.* A .* B)/((x).^2 + A .* (x) + A .* B)) / S) - 1).^3 / T);
dydt = [dydt(1),dydt(2),dydt(3),dydt(4),dydt(5),dydt(6),dydt(7)];
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by