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