double loop plot !!

조회 수: 3 (최근 30일)
Karim Ayman
Karim Ayman 2015년 10월 18일
댓글: Walter Roberson 2025년 6월 12일
I need do draw a chart showing the change in value (COP) Related to the relation COP=Te/Tc-Te Where Te=-15:10 and Tc=30:50 I want to plot (COP,Te) for each value of Tc Keeping all the plots in one graph Any help !
  댓글 수: 1
Walter Roberson
Walter Roberson 2025년 6월 12일
Te = (-15:10).';
Tc=30:50;
COP = Te ./ Tc - Te;
surf(Tc, Te, COP)

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

답변 (1개)

Aditya
Aditya 2025년 6월 12일
Hi Karim,
You can use a single for loop to compute COP values for each Tc and plot them together in one graph:
Te = -15:10;
Tc = 30:50;
hold on; % Keep all plots in one graph
for tc = Tc
COP = Te ./ (tc - Te); % Compute COP for the current Tc
plot(Te, COP, 'DisplayName', ['Tc = ' num2str(tc)]); % Plot COP vs Te
end
xlabel('Te');
ylabel('COP');
title('COP vs Te for different Tc values');
legend show;
grid on;
hold off;
I hope this helps!

카테고리

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