How can I write multiple number (digit) in my title?

8 ビュー (過去 30 日間)
Ashfaq Ahmed
Ashfaq Ahmed 2022 年 8 月 24 日
コメント済み: Ashfaq Ahmed 2022 年 8 月 24 日
Hi! So, I have this mode array and I want to write this title -
mode = [1,2,3,4,5];
title(sprintf('Mode: %d',mode(1,1)));
But sometimes for other figures, I might need to show multiple modes. For example -
title(sprintf('Mode: %d, %d, %d',mode(1,1),mode(1,2),mode(1,3)));
Can anyone please tell me how can I show it without repeating the %d? or the mode(i,j)?
Say, one title might be "Mode: 1,2,3,4". How can I code it automatically so that I don't have to manually check the %d?
Thank you so much!

採用された回答

Dave B
Dave B 2022 年 8 月 24 日
I think what you're saying is you don't want to compute how many %d's to include and just have all the value separated by commas?
How about:
mode = [1,2,3,4,5];
title("Mode: " + string(mode).join(", "))
  1 件のコメント
Ashfaq Ahmed
Ashfaq Ahmed 2022 年 8 月 24 日
Thank you brother! You made my life easy!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by