How to display a long string in multiple lines?
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jing Ci Neo
le 17 Sep 2018
Commenté : giannit
le 30 Mar 2021
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.
0 commentaires
Réponse acceptée
Walter Roberson
le 17 Sep 2018
PerLine = 80;
pattern = sprintf('.{1,%d}', PerLine);
str = regexp(C{n,1}, pattern, 'match');
fprintf('%s\n', str{:});
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!