next line, new line! in the text( ) code

I want to write text using text code
text(5,5,['MATLAB','\n']);
but '\n' doesn't work.
I want a textbox consisting of three text lines

 採用された回答

Image Analyst
Image Analyst 2012 年 11 月 9 日
編集済み: Image Analyst 2012 年 11 月 9 日

12 投票

Try sprintf:
message = sprintf('Line #1\nThe second line.\nAnd finally a third line.');
plot(1:20);
text(5, 5, message, 'FontSize', 20, 'Color', [.6 .2 .6]);

その他の回答 (1 件)

Jan
Jan 2012 年 11 月 9 日

21 投票

text(5, 5, ['MATLAB', char(10), 'Line 2']);
text(10, 5, {'MATLAB2', 'Line 2'});

1 件のコメント

Jim Royalty
Jim Royalty 2017 年 5 月 17 日
This answer works. My \n didn't.

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

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

製品

タグ

質問済み:

2012 年 11 月 9 日

コメント済み:

2017 年 5 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by