Why do I get "Array indices must be positive integers or logical values"
Afficher commentaires plus anciens
I am trying to solve the following differential equation ode3. Tc_p is a cfit that I change to a symfun so I can susbtitute inside my differential equation and solve the whole thing. I can`t understand why I am getting the error "Array indices must be positive integers or logical values.". Thx in advanace.
clear all
datos_TH;
syms Tfav(t) Tcav(t) Tm(t)
cond1=Tfav(0)==(Tf0-Tm0)/(Tf0-Tm0);
cond2=Tcav(0)==(Tc0-Tm0)/(Tf0-Tm0);
%cond3=Tm(0)==Tm0;
conds=[cond1; cond2];
ode1=diff(Tfav)==-2*Bigf*(Tfav-Tcav)/Rf0 + 100;
ode2=diff(Tcav)==2*K*(Bigc*Rci*(Tfav-Tcav)-Bi(1)*Tcav)/(1-Rci^2);
%ode3=diff(Tm)==(Sc*hi(1)*(Tc-Tm)-2*m*cp*(Tm-Tm0))/(Mc*cp);
odes=[ode1;ode2];
[TcavSol(t), TfavSol(t)]=dsolve(odes, conds);
Tf=[];
Tc=[];
n=1;
t_0=25;
time_ad=t_0*kf/(Rhof*cf*rc0^2);
for i=0:0.01:time_ad
Tf(n)=double(TfavSol(i))*(Tf0-Tm0) + Tm0;
Tc(n)=double(TcavSol(i))*(Tf0-Tm0) + Tm0;
n=n+1;
m=n+1;
end
%Moderator Temperature ODE
save('Tc','Tc');
t=linspace(0,t_0,m-2);
t=transpose(t);
Tc=transpose(Tc);
Tc_p=fit(t,Tc,'poly8');
Tc_p=subs(str2sym(formula(Tc_p)),coeffnames(Tc_p),num2cell(coeffvalues(Tc_p).'));
Tc_p=subs(Tc_p,'t');
cond3=Tm(0)==Tm0;
ode3=diff(Tm,'t')==(Sc*hi(1)*(Tc_p-Tm)-2*m*cp*(Tm-Tm0))/(Mc*cp);
odes=ode3;
TmSol(t)=dsolve(ode3,cond3);
And the complete error is:
Array indices must be positive integers or logical values.
Error in sym/privsubsasgn (line 1311)
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
Error in indexing (line 1142)
C = privsubsasgn(L,R,inds{:});
Error in Sim_TH (line 41)
TmSol(t)=dsolve(ode3,cond3);
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 27 Avr 2023
0 votes
See the FAQ for a thorough discussion:
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!