Cannot get these errors to clear.

3 次查看(过去 30 天)
Abby Revoir
Abby Revoir 2020-10-1
>> 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

回答(1 个)

Cris LaPierre
Cris LaPierre 2020-10-2
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 个评论
Cris LaPierre
Cris LaPierre 2020-10-2
Use semicolons to create your output variable.
output = [dFAdV;dFBdV;dFCdV;dTdV];
Abby Revoir
Abby Revoir 2020-10-2
It finally worked!! Thank you!!!!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by