Merge Three Figures Into One

조회 수: 2 (최근 30일)
JC.UT
JC.UT 2021년 2월 3일
댓글: JC.UT 2021년 2월 3일
This will generate 3 separate figures , how can I get it onto one figure ?
clear all;
clc;
hi=5.5*1e6; %heat input=5.5*10^(-6) Btu/h
time=4200; %time=4200 hours
cost=[4*1e-6,5*1e-6,6*1e-6]; %cost is per million Btu
eff1=0.7; %efficiency = 0.7
%tuning efficiency varying from 0.7 to 0.9
eff=linspace(0.7,0.9,10);
for i=1:3
j=1;
for eff2=linspace(0.7,0.9,10);
annual_energy(j)=hi*time*eff2;
cost_saving(j)=cost(i)*hi*time*(eff2-eff1);
j=j+1;
end
figure %opens new figure
[hAx,hLine1,hLine2]=plotyy(eff,annual_energy,eff,cost_saving);
xlabel('Efficiency');
ylabel(hAx(2),'Cost saving in $');
ylabel(hAx(1),'Annual Energy in Btu');
legend('Annual Energy','Cost Saving');
title(['Annual Energy and Cost Saving vs Efficiency at $',num2str(cost(i))]);
end

채택된 답변

VBBV
VBBV 2021년 2월 3일
clear all;
clc;
hi=5.5*1e6; %heat input=5.5*10^(-6) Btu/h
time=4200; %time=4200 hours
cost=[4*1e-6,5*1e-6,6*1e-6]; %cost is per million Btu
eff1=0.7; %efficiency = 0.7
%tuning efficiency varying from 0.7 to 0.9
eff=linspace(0.7,0.9,10);
for i=1:3
j=1;
for eff2=linspace(0.7,0.9,10);
annual_energy(j)=hi*time*eff2;
cost_saving(j)=cost(i)*hi*time*(eff2-eff1);
j=j+1;
end
subplot(3,1,i)%figure %opens new figure
[hAx,hLine1,hLine2]=plotyy(eff,annual_energy,eff,cost_saving);
xlabel('Efficiency');
ylabel(hAx(2),'Cost saving in $');
ylabel(hAx(1),'Annual Energy in Btu');
legend('Annual Energy','Cost Saving');
title(['Annual Energy and Cost Saving vs Efficiency at $',num2str(cost(i))]);
end
  댓글 수: 2
VBBV
VBBV 2021년 2월 3일
use a subplot for merging figures
JC.UT
JC.UT 2021년 2월 3일
Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by