Question about plotting graph.
14 views (last 30 days)
Show older comments
Sun Wook Han
on 24 Jan 2021
Commented: Mischa Kim
on 25 Jan 2021
The code below is how I got T1.
Now, I'd like to plot T1 vs T0(it was a fixed value 450).
What code should I input here?
I tried
T0 = linspace (273, 500);
plot (T0, y)
but it doesn't work
Please, advise. Thank you in advance.
clc, clear all; close all;
syms T1
U = 8000; % cal/(min*C)
Cp0 = 50; % cal/(mol*C)
Fa0 = 80; % 80mol/min
E = 40000; % cal/mol
H = -7500; % cal/mol
t = 100; % min^-1
T0 = 450; % K
Ta = 300; % K
T2 = 350; % K
R = 1.987; % cal/(mol*K)
k2 = 6.6*10^-3; % min^-1
%Heat removed
k = U/(Cp0*Fa0);
Tc = (k*Ta+T0)/(1+k);
Rt = Cp0*(1+k)*(T1-Tc);
%Heat generated
k1 = k2*exp((E/R)*((1/T2)-(1/T1)));
Gt = -H*t*k1/(1+(t*k1));
y = vpasolve (Rt == Gt, T1)
0 Comments
Accepted Answer
Walter Roberson
on 24 Jan 2021
For some T values, there are two solutions; which one you get depends upon the starting point for your search.
t0 = linspace(273, 500, 350);
nt = length(t0);
syms T1 T0 real
U = 8000; % cal/(min*C)
Cp0 = 50; % cal/(mol*C)
Fa0 = 80; % 80mol/min
E = 40000; % cal/mol
H = -7500; % cal/mol
t = 100; % min^-1
%T0 = 450; % K
Ta = 300; % K
T2 = 350; % K
R = 1.987; % cal/(mol*K)
k2 = 6.6*10^-3; % min^-1
%Heat removed
k = U/(Cp0*Fa0);
Tc = (k*Ta+T0)/(1+k);
Rt = Cp0*(1+k)*(T1-Tc);
%Heat generated
k1 = k2*exp((E/R)*((1/T2)-(1/T1)));
Gt = -H*t*k1/(1+(t*k1));
eqns = subs(Rt == Gt, T0, t0);
y = zeros(1, nt);
old = 200;
for K = 1 : nt
sol = double(vpasolve(eqns(K), T1, old));
if isempty(sol)
y(K) = nan;
else
y(K) = sol;
old = sol;
end
end
plot(t0, y, 'b-')
y1 = zeros(1, nt);
old = 500;
for K = 1 : nt
sol = double(vpasolve(eqns(K), T1, old));
if isempty(sol)
y1(K) = nan;
else
y1(K) = sol;
%old = sol;
end
end
plot(t0, y1, 'b-')
y2 = zeros(1, nt);
old = 350;
for K = 1 : nt
sol = double(vpasolve(eqns(K), T1, old));
if isempty(sol)
y2(K) = nan;
else
y2(K) = sol;
%old = sol;
end
end
plot(t0, y2, 'b-')
0 Comments
More Answers (1)
Mischa Kim
on 24 Jan 2021
Edited: Mischa Kim
on 24 Jan 2021
Hi, how about
plot(T0,y,'ro')
Since this is only one single data point it is hard to see in the plot, hence I change the color and shape.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!