Graphing multiple graphs in one figure

조회 수: 1 (최근 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 CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by