How to plot 50 figures each has 3 curves for loop

I have a for loop that does calculation of three arrays and then I plot them in one figure. I plan to do the same for 50 figures.
for i=1:numel(x)
pcf(i)=pmd(i)/s(i);
pc(i)=pld(i)/s(i);
ph(i)=pud(i)/s(i);
end
pcf;
pc;
ph;
plot(x,pc,'g')
hold on
plot(x,pcf,'b')
plot(x,ph,'r')

댓글 수: 3

KSSV
KSSV 2021년 12월 15일
Not a problem, you calculate them and plot. But showing 50 curves in a single figure doesn't show up the results. What you expect ?
Thanks for the feedback! I plan to plot 50 different figures. each figure has three curves calculated by for loop. The issue I faced is that the 50 figures are being made in a single figure.
Jan
Jan 2021년 12월 15일
편집: Jan 2021년 12월 15일
What is the purpose of these lines:
pcf;
pc;
ph;
Isn't this a waste of time only?
You can simplify:
for i=1:numel(x)
pcf(i)=pmd(i)/s(i);
pc(i)=pld(i)/s(i);
ph(i)=pud(i)/s(i);
end
% to:
pcf = pmd ./ s;
pc = pld ./ s;
ph = pud ./ s;
% No loop needed.

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

 채택된 답변

Jan
Jan 2021년 12월 15일
You show us the code to create one set of lines. Then simply add this command before plotting:
figure()
axes('NextPlot', 'add'); % as: hold on (which can be omitted then)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 12월 15일

댓글:

2021년 12월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by