Display long strings that include newlines in a table
Show older comments
I want to create and display a table in a live script. One of the colums is a string. In some cases, this string is very long, and the column is much wider than the viewable area of the script. I have inserted newlines in the string to insure there are no more than say N characters between each newline, but when I display the string in a table the cell containing the string contains only a single row of characters with a small character that looks like a carriage return at the location of each new line. Is there a way to display multi-line strings in a table?
Accepted Answer
More Answers (1)
I don't think there's a way. But you could write to an Excel file (e.g., with writetable) where multiline cells are possible.
>> s="aaa"+sprintf('\n')+"bb"
s =
"aaa
bb"
>> T=table(s)
T =
table
s
_________
"aaa↵bb"
>> writetable(T,'tst.xls')

1 Comment
There are also ways to use actxserver to open/close/maximize an Excel file from Matlab, if you wanted to use Excel as a surrogate display window.
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!