Question about plotting graph.

26 views (last 30 days)
Sun Wook Han
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)

Accepted Answer

Walter Roberson
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-')

More Answers (1)

Mischa Kim
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.
  2 Comments
Sun Wook Han
Sun Wook Han on 24 Jan 2021
Edited: Sun Wook Han on 24 Jan 2021
How do I need to define T0?
I tried
T0 = linspace(273, 500)
plot (T0, y, 'ro')
but it doesn't work.
the error message says..
Error using mupadengine/feval_internal
More equations than variables is only supported for
polynomial systems.
Error in sym/vpasolve (line 172)
sol =
eng.feval_internal('symobj::vpasolve',eqns,vars,X0);
Error in Untitled3 (line 28)
y = vpasolve (Rt == Gt, T1)
Mischa Kim
Mischa Kim on 25 Jan 2021
I misinterpreted your question. Thanks, @Walter Roberson for providing an excellent answer.

Sign in to comment.

Categories

Find more on Graphics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!