Obtain imaginary numbers in for loop but running code at each step on its own produces absolute numbers

조회 수: 1 (최근 30일)
The following is the code I have created. I know the equations are correct because running utside a forloops fofr each step gives me the corect values and the creating a table in excel gives me the correct values. I've also tried plotting (tr/tg, x), which should give a curve but these values give a linear trend.
%Constants
T = 375;% C
Tk = T+273.15; %Kelvin
a = 1;
b = 2;
c = 1;
d = 2;
densB = 3400; %kg/m3
mmB = 0.134452;%kg/mol
P = 100000; %Pa
R1 = 8.31446; %m3-Pa/K-mol
%Reaction kinetics
k = 0.00011; % m3/m2-s
De = 0.00000000203; %m2/s
Cb0 = densB/mmB; % mol/m3, average steam concentration
Ca0 = (0.21*P)/(R1*Tk); % mol/m3
%Time and SCM
d = 200;
x(1) = 0; %initial conversion values
n = 0.01;
for i=1:101
Rp = (d./2)./1000000
taug = ((Cb0.*(Rp.^2))./(6.*b.*De.*Ca0))
taur = ((Cb0.*Rp)./(b*k*Ca0))
diff = (1-(3.*((1-x).^(2/3)))+(2.*(1-x)))
reac = (1-((1-x).^(1/3)))
Tcg = (taug.*diff)/60
Tcr = (taur.*reac)/60
x(i+1) = x(i) + n;
end

답변 (1개)

Torsten
Torsten 2022년 10월 20일
편집: Torsten 2022년 10월 20일
diff = (1-(3.*((1-x(i)).^(2/3)))+(2.*(1-x(i))))
reac = (1-((1-x(i)).^(1/3)))
instead of
diff = (1-(3.*((1-x).^(2/3)))+(2.*(1-x)))
reac = (1-((1-x).^(1/3)))
And make an array out of the variable you want to plot against x, e.g.
diff(i) = ...
reac(i) = ...
Tcg(i) = ...
Tcr(i) = ...
And the loop should run up to 100, not 101.

카테고리

Help CenterFile Exchange에서 Physics에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by