Indices in discrete mass and temperature balance

조회 수: 2 (최근 30일)
Bas Haar
Bas Haar 2019년 11월 29일
답변: Image Analyst 2019년 11월 29일
Hello all,
I'm trying to model a plug-flow reactor where mass and temperature are changing over the z-axis. Therefore, I have 2 equations, dC/dz (concentration) and dT/dz (temperature), and I have them in discrete form such that the next point can be calculated on the basis of the updated values of both T and C.The part of the code concerning this system of equations that I currently have is given below. Consider all constants (AR,q,k0) and initial conditions (CEO(end) and T) to be fine and given. The problem I'm getting is that in the Temp(n+1) line it states: 'Subscript indices must either be real positive integers or logicals'. However, CEO2(2) does give a value, while all indices are the same. Can anyone see what the issue is here? Thanks in advance!
n = 1;
i = 20;
f = @(z,CEO2,Temp) (-AR/q)*k0*(exp(-Ea/(R*Temp)))*B0*CEO2;
g = @(z,CEO2,Temp) (AR/(q*rho*cp))*-dH*k0*(exp(-Ea/(R*Temp)))*B0*CEO2;
dz = h/i
CEO2(1) = CEO*(end)*1000
Temp(1) = T;
z(1) = 0;
while (z(n) <= h)
CEO2(n+1) = CEO2(n) + dz*f(z(n), CEO2(n), Temp(n))
Temp(n+1) = Temp(n) + dz*g(z(n), CEO2(n), Temp(n))
z(n+1) = z(n) + dz
n = n+1;
end

답변 (1개)

Image Analyst
Image Analyst 2019년 11월 29일

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by