How to plot this function in chemical reactor
2 views (last 30 days)
Show older comments
%%steady state plotting
T0=[290 298 305]; %%T -initial
Tr=270:1:370; %%T - range
figure
plot(Tr,mass_balance(Tr), Tr,energy_balance(Tr,T0))
hold on
plot(Tr,energy_balance(Tr,T0(3)), Tr, energy_balance(Tr,T0(2)), Tr,energy_balance(Tr,T0(1)))
hold off
function X=mass_balance(T)
VR=2000; %dm3 reactor volume
V=300; %l/min
tr=VR/V; %
cao=4; %mol/l
cp=3.5; %J/g/K
rho=1150; %g/dm3
dHr=-50000; %J/mol
k=2.4e15.*exp(-12000./T); %
X=k*tr/(1+k*tr); %converse
end
function Xeb=energy_balance(T)
VR=2000; %dm3
V=300; %l/min
tr=VR/V;
cao=4; %mol/l
cp=3.5; %J/g/K
rho=1150; %g/dm3
dHr=-50000; %J/mol
T0=[290 298 305];
k=2.4e15.*exp(-12000./T);
Xeb=rho.*cp.*(T-T0)./((-dHr).*cao); %converse
end
%%And this is the solution, that i cant get it..
Could tell me please, how plotting this, i dont understand this. Thanks for your help.
3 Comments
Scott MacKenzie
on 30 Apr 2021
You need to do some more debugging here. For your plot command above, the x vectors are all Tr. That's fine. Try assigning the y values to variables:
y1 = energy_balance(Tr,T0(1));
y2 = energy_balance(Tr,T0(2));
y3 = energy_balance(Tr,T0(3));
and then insert those variables into plot as follows:
plot(Tr, y1, Tr, y2, Tr, y3);
You'll get the same error message ("Error using plot Vectors must be the same length"). So, have look at the length of the vectors. Are Tr and y1 the same length, as they must be? Your thinking should be something like... Hmm, Gee, Ah Ha, OK, Yes, I get it! Let's fix that.
Good luck
Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!