legend for graphs by while loop

how to make a legend for the plot generated by the below code (this is an example code)
the legend look like (plot # , for ca = k)
figure();
hold on
k = 1e-3;
while ( k <=1.0 )
ca = k;
j = 1.0;
while (j > 1e-10)
while (condition) >= abs(1e-5)*j)
[T, H] = ode45(XXX);
end
j = j * 1e-1;
end
plot(T, H(:,1))
xlim([0 15])
end
k = k*10.0;
end
hold off

 採用された回答

Kanika Gupta
Kanika Gupta 2020 年 6 月 25 日
編集済み: Kanika Gupta 2020 年 6 月 25 日

0 投票

You can add legend in the plot command or use the legend function as mentioned in the documentation. Please follow the documentation given here https://in.mathworks.com/help/matlab/creating_plots/add-legend-to-graph.html
In order to help you better please share the entire code to view the generated figure

2 件のコメント

matlab
matlab 2020 年 6 月 25 日
I know how to make a legend, but not for a graph generated by while loop
could you elaborate more using my example
dpb
dpb 2020 年 6 月 25 日
Look at the examples at the doc for legend -- there's nothing different about whether mutiple lines were added with a for...end loop or manually.
Just try something...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2020 年 6 月 25 日

コメント済み:

dpb
2020 年 6 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by