name several curves within a loop

5 ビュー (過去 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 Center および File ExchangeFit Postprocessing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by