How to display a long string in multiple lines?

11 ビュー (過去 30 日間)
Jing Ci Neo
Jing Ci Neo 2018 年 9 月 17 日
コメント済み: giannit 2021 年 3 月 30 日
I have a cell called C containing many strings, of which some are very long and it's hard to view in one line. I want to be able to call these strings and print them but in multiple lines: str=C{n,1}; fprintf('%s\n',str)
How I would be able to do that? Any help would be greatly appreciated.

採用された回答

Walter Roberson
Walter Roberson 2018 年 9 月 17 日
PerLine = 80;
pattern = sprintf('.{1,%d}', PerLine);
str = regexp(C{n,1}, pattern, 'match');
fprintf('%s\n', str{:});
  2 件のコメント
Jing Ci Neo
Jing Ci Neo 2018 年 9 月 20 日
Yes it worked very well, thank you!
giannit
giannit 2021 年 3 月 30 日
Thank you i was looking for that!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by