How to plot more than 3 lines on a graph?

7 次查看(过去 30 天)
Will Jeter
Will Jeter 2020-11-11
回答: ag 2024-11-7,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;

回答(1 个)

ag
ag 2024-11-7,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!

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by