Calling a derived value as legends in plot

3 ビュー (過去 30 日間)
shahzer rahman
shahzer rahman 2020 年 4 月 2 日
編集済み: Birdman 2020 年 4 月 2 日
Hi
I am trying to use a derived value from a for loop as my legend entries. Is there a way to do it?
Zeta= [ 1 2 3 4 5]. These are the values i want to use as the legend entries for a plot that has 5 different curves, all of them calculated using a for loop.
I dont want to manually input these values into the legend function like
legend('1','2','3','4','5')
Instead I want legend to automatically take all the values from the matrix 'Zeta'.
Kindly help. Thanks for your time.

回答 (1 件)

Birdman
Birdman 2020 年 4 月 2 日
編集済み: Birdman 2020 年 4 月 2 日
After the loop, run the following line:
legend(reshape(sprintf('%d',Zeta),numel(Zeta),1))

カテゴリ

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