Cannot get these errors to clear.

>> 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

Antworten (1)

Cris LaPierre
Cris LaPierre am 2 Okt. 2020

0 Stimmen

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 Kommentare

Abby Revoir
Abby Revoir am 2 Okt. 2020
Bearbeitet: Abby Revoir am 2 Okt. 2020
I defined that. Now getting these:
Error using odearguments (line 18)
When the first argument to ode45 is a function handle, the tspan and
y0 arguments must be supplied.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options,
varargin);
Error in solve_ODEs_CA3 (line 4)
[V,y] = ode45(@(V,C)ODEs_CA3(tspan,y0));
Cris LaPierre
Cris LaPierre am 2 Okt. 2020
Bearbeitet: Cris LaPierre am 2 Okt. 2020
Follow the syntax shown in the documentation for ode45:
[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
Abby Revoir am 2 Okt. 2020
Okay awesome i did all that as well and fixed a few more typos. Now getting this :(
>> solve_ODEs_CA3
Unrecognized function or variable 'dFCdV'.
Error in solve_ODEs_CA3/ODEs_CA3 (line 54)
ouput = [dFAdV:dFBdV:dFCdV:dTdV];
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);
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
Abby Revoir am 2 Okt. 2020
Okay, so i fixed all my typos i think and now get this:
>> solve_ODEs_CA3
ans =
1 0
Error using odearguments (line 95)
SOLVE_ODES_CA3/ODES_CA3 returns a vector of length 1, but the length of initial conditions vector is 4. The
vector returned by SOLVE_ODES_CA3/ODES_CA3 and the initial conditions vector must have the same number of
elements.
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);
Use semicolons to create your output variable.
output = [dFAdV;dFBdV;dFCdV;dTdV];
Abby Revoir
Abby Revoir am 2 Okt. 2020
It finally worked!! Thank you!!!!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2020a

Tags

Gefragt:

am 1 Okt. 2020

Kommentiert:

am 2 Okt. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by