How to plot more than 3 lines on a graph?

7 views (last 30 days)
Will Jeter
Will Jeter on 11 Nov 2020
Answered: ag on 7 Nov 2024 at 10:42
I can get R, G, R1 to show up on my graph, but when I add R2 it doesnt show up and all my graph labels disappear. Please help
figure
hold all
plot(T,R)
plot(T,G)
plot(T,R1)
plot(T,R2)
legend('R(T)','G(T)','Ta=250K','Ta=210K')
xlabel('Temperature (K)')
ylabel('G(T) and R(T) (cal/mol)')
title('G(T) and R(T) vs. T')
T = [310:1:450];
v = 1;
V = 10;
dHrxn = -80000;
UA = 3600;
kf0 = 1;
kc0 = 100;
T0 = 400;
ER = 20000;
CpA = 40;
kf = exp(-20000*(1./T-1/400));
kc = 100*exp((80000/1.987)*(1./T-1/400));
x = 1./(v./(V.*kf)+1+(1./kc));
R = 400*(T-310);
R1 = 400*(T-256);
R2 = 400*(T-220);
G = x*-dHrxn;

Answers (1)

ag
ag on 7 Nov 2024 at 10:42
Hi Will,
The issue you are encountering arises from using the variables "T," "R," "G," "R1," and "R2" prior to their initialization.
Below is a revised version of your code, which addresses this matter:
T = [310:1:450];
v = 1;
V = 10;
dHrxn = -80000;
UA = 3600;
kf0 = 1;
kc0 = 100;
T0 = 400;
ER = 20000;
CpA = 40;
kf = exp(-20000*(1./T-1/400));
kc = 100*exp((80000/1.987)*(1./T-1/400));
x = 1./(v./(V.*kf)+1+(1./kc));
R = 400*(T-310);
R1 = 400*(T-256);
R2 = 400*(T-220);
G = x*-dHrxn;
figure
hold all
plot(T,R)
plot(T,G)
plot(T,R1)
plot(T,R2)
legend('R(T)','G(T)','Ta=250K','Ta=210K')
xlabel('Temperature (K)')
ylabel('G(T) and R(T) (cal/mol)')
title('G(T) and R(T) vs. T')
Hope this helps!

Categories

Find more on Graph and Network Algorithms 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!