Azzera filtri
Azzera filtri

How to display a long string in multiple lines?

24 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Walter Roberson
Walter Roberson il 17 Set 2018
PerLine = 80;
pattern = sprintf('.{1,%d}', PerLine);
str = regexp(C{n,1}, pattern, 'match');
fprintf('%s\n', str{:});
  2 Commenti
Jing Ci Neo
Jing Ci Neo il 20 Set 2018
Yes it worked very well, thank you!
giannit
giannit il 30 Mar 2021
Thank you i was looking for that!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by