name several curves within a loop

조회 수: 6 (최근 30일)
Nitin
Nitin 2012년 9월 4일
댓글: surendra bhatta 2019년 3월 15일
Hello,
I am plotting about 80 curves on the same plot.
In order to differentiate between each curve, i would like to name each curve on the plot within the for loop shown below:
for k = 1:80
[a,b]=test(a1,b1);
labels = cellstr(num2str([k]')); % not sure about this one*bold*
h=plot_curves(a, b, 'r',5);
hold on
end
Thanks,
Ash

채택된 답변

Matt Fig
Matt Fig 2012년 9월 4일
편집: Matt Fig 2012년 9월 4일
You could put a text on each curve. But placing the text could be tricky with that many curves on one plot.
x = 0:.01:1;
L = floor(length(x)/2);
hold all
for ii = 1:4
plot(x,x.^ii)
text(x(L),x(L).^ii,sprintf('%i',ii))
end
  댓글 수: 1
surendra bhatta
surendra bhatta 2019년 3월 15일
my entire curve is filling with the text. what might be the solution

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 9월 4일
labels{k} = num2str(k);
Then at the end of the loop,
legend(labels)
This assumes that plot_curves is constructing exactly one line object per loop iteration.

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by