フィルターのクリア

How to insert loop variable inside plot label?

5 ビュー (過去 30 日間)
Riccardo Canola
Riccardo Canola 2018 年 9 月 30 日
コメント済み: Star Strider 2018 年 9 月 30 日
I want to insert the value of the loop variable inside a label next to a string. How do I do it?
for i = 1:n
subplot(1,n,i)
plot(1:m,THETA(i,:))
hold on
plot(1:m+1,THETA_est_rls(i,:))
plot(1:m+1,THETA_est_ewrls(i,:))
legend('true','RLS','EWRLS')
xlabel('Iterations');
ylabel('\theta', i);

採用された回答

Star Strider
Star Strider 2018 年 9 月 30 日

I assume you want to include it in your ylabel call.

This works:

ylabel(sprintf('\\theta %d', i));

The double \\ are necessary to get one of them to print correctly. (The leading \ operates as an ‘escape’ character.)

  6 件のコメント
Riccardo Canola
Riccardo Canola 2018 年 9 月 30 日
Awesome. Thanks again!
Star Strider
Star Strider 2018 年 9 月 30 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by