Cannot get these errors to clear.
Afficher commentaires plus anciens
>> solve_ODEs_CA3
Unrecognized function or variable 'Cto'.
Error in solve_ODEs_CA3/ODEs_CA3 (line 37)
CA = Cto*(Fa/Ft) * (To/T);
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 solve_ODEs_CA3 (line 4)
[V,y] = ode45(@ODEs_CA3,tspan,y0);
>>
function solve_ODEs_CA3()
tspan = (0:0.01:1);
y0 = [100 0 0 423];
[V,y] = ode45(@ODEs_CA3,tspan,y0);
plot(V,y(:,1),'-o',V,y(:,2),'-o',V,y(:,3),'-o')
title('Temperature Profile');
xlablel('V(dm^3)');
ylabel('t(k)');
legend('F_A','F_B','F_C','T');
function output = ODEs_CA3 (~,y)
Fa = y(1);
Fb = y(2);
Fc = y(3);
T = y(4);
deltaH1 = -20000;
deltaH2 = -60000;
CPA = 90;
CPB = 90;
CPC = 180;
Ua = 4000;
Ta = 373;
ER1 = 4000;
ER2 = 9000;
T0 = 423; %Setting values for first set of variables
%Eq. for K1A and K2A
K1A = 10*exp(ER1*((1/300)-(1/T)));
K2A = 0.09*exp(ER2*((1/300)-(1/T)));
%Eq. for FT
Ft = Fa + Fb + Fc;
%Eq. for CA, CB, CC
CA = Cto*(Fa/Ft) * (To/T);
CB = Cto*(Fb/Ft)*(To/T);
CC = Cto*(Fc/Ft)*(To/T);
%Eq. for RA1 and RA2
RA1 = -K1A*CA;
RA2 = -K2A*(CA)^2;
%Eq. for dFa, DFb, and Dfc derivatives
dFAdV = RA1 +RA2;
dFBdV = -RA1;
dFCdv = -(1/2)*(-RA2);
%Derivative of dT eq.
dTdV = (Ua*(Ta-T)+(-RA1)*(deltaH1)+(-RA2)*(-deltaH2))/((Fa*CPA)+(Fb*CPB)+(Fc+CPC));
ouput = [dFAdV;dFBdV:dFCdV;dTdV];
size(output)
end
end
Réponses (1)
Cris LaPierre
le 2 Oct 2020
0 votes
Your equations for CA, CB, CC in ODEs_CA3 function use a variable Cto that has not been created or at least does not exist within the scope of that function. You either need to define it, or pass it in as input to the function.
7 commentaires
Abby Revoir
le 2 Oct 2020
Modifié(e) : Abby Revoir
le 2 Oct 2020
Cris LaPierre
le 2 Oct 2020
Modifié(e) : Cris LaPierre
le 2 Oct 2020
[t,y] = ode45(odefun,tspan,y0)
It looks like your are using [V,y] = ode45(@(V,C)ODEs_CA3(tspan,y0));
Try this instead:
[V,y] = ode45(@ODEs_CA3,tspan,y0);
There are several other typos in your code, but once you fix those, your code runs and produces a figure (I had to make up a value for Cto so the code would run).

Abby Revoir
le 2 Oct 2020
Steven Lord
le 2 Oct 2020
You define a variable dFCdv but then try to use a variable dFCdV. Lower-case v and upper-case V are not interchangeable.
dFCdv = -(1/2)*(-RA2);
ouput = [dFAdV:dFBdV:dFCdV:dTdV];
You also don't want to use the colon operator : here, you want to separate the variables with semicolons ;.
Abby Revoir
le 2 Oct 2020
Cris LaPierre
le 2 Oct 2020
Use semicolons to create your output variable.
output = [dFAdV;dFBdV;dFCdV;dTdV];
Abby Revoir
le 2 Oct 2020
Catégories
En savoir plus sur Programming 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!