Graphing multiple graphs in one figure

8 ビュー (過去 30 日間)
Avery Herbert
Avery Herbert 2020 年 1 月 30 日
回答済み: Cameron B 2020 年 1 月 30 日
We have this rankine cycle power plant and we just recently graphed the Cycle Efficiency and Net profit/loss as the boiler pressure varied from 5 to 15 MPa. Now we are required to change the turbine efficiency from .75 to .90 in 5 percent increments. Basically we are trying to graph make 4 different curves one for each different type of efficiency but we are struggling finding a way to find all four of those different curves and hold them. Below is the current code we are using to graph the cycle eff and net profit/loss.
BP=zeros(1,6);
for i=5:2:15
x=0.5*(i-5)+1;
BP(x)=i;
State2_value(x)=steam_properties('P',BP(x),'s',State1.s_l,'SI');
State3_value(x)=steam_properties('P',BP(x),'s',6.6797,'SI');
State4_value(x)=steam_properties('P',State1.P,'s',State3.s,'SI');
W_turbine(x)=State3_value(x).h-State4_value(x).h;
Q_boiler(x)=State3_value(x).h-State2_value(x).h;
efficiency(x)=1-abs(q_condenser/Q_boiler(x));
cost(x)=3/(10^6)*(0.9478)*(20*10^3)*(3600)*(365)*(24)*(1/efficiency(x));
net1(x)=sales-cost(x);
end
figure
subplot(2,1,1);
plot(BP,efficiency,'LineWidth',2);
title('Boiler Pressure Dependency');
xlabel('Boiler Pressure (MPa)');
ylabel('Cycle Efficiency');
axis([5 15,0.35 0.45]);
subplot(2,1,2);
plot(BP,net1,'LineWidth',2);
title('Boiler Pressure Dependency');
xlabel('Boiler Pressure (MPa)');
ylabel('Net Profit/Loss ($)');
axis([5 15,-6e5 4e5]);
  1 件のコメント
Avery Herbert
Avery Herbert 2020 年 1 月 30 日
We figure we need to make a for loop inside of a for loop but we do not know how to hold on to each different curve in order to put them all on one graph.

サインインしてコメントする。

回答 (1 件)

Cameron B
Cameron B 2020 年 1 月 30 日
%Use hold on and hold off
clear
clc
xx=transpose(1:10);
hold on
for hh = 1:6
randvec(:,hh) = hh*xx.^2;
plot(xx,randvec(:,hh))
legendvec{hh} = sprintf('graph # %s',string(hh));
end
hold off
legend(legendvec,'Location','northwest')

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by