Too many input arguments, which arguments should I remove?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Dursman Mchabe
il 23 Ott 2018
Commentato: Walter Roberson
il 24 Ott 2018
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 Commenti
KSSV
il 24 Ott 2018
YOur code is very buggy.......need lot's of changes.....what you are trying actually?
Risposta accettata
Walter Roberson
il 24 Ott 2018
Your function line for odes needs to list A, B, C, and so on.
3 Commenti
Torsten
il 24 Ott 2018
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
il 24 Ott 2018
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
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!