How to change legends' name

155 ビュー (過去 30 日間)
Lydia Abigail Garza Coello
Lydia Abigail Garza Coello 2021 年 5 月 19 日
編集済み: the cyclist 2021 年 5 月 19 日
Hi,
I have a code for plotting different curves that appears as time increases. The number of curves that are displayed depends on the input data each time I run the program, so I could have 6, 8, 10, etc., curves (unknown). My problem is that I want to label each of the curves as "Theta n" (n is 1,2,3,4....) but I don´t know how to include that in the legend command. The graph is like the following image:
Thanks,
Abby

採用された回答

the cyclist
the cyclist 2021 年 5 月 19 日
編集済み: the cyclist 2021 年 5 月 19 日
Here is a basic way you can do it:
N = 3;
figure
hold on
for ii = 1:N
plot(rand(1,7),'DisplayName',sprintf('Theta %d',ii))
end
legend()

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by