MATLAB Answers

How to have multiple lines in a table variable name?

7 views (last 30 days)
Can you change the interpreter of the table to format variable names? Both of these examples fail to accomplish the goal:
% Example 1: sprintf().
varName = { sprintf( 'A multi-\nline name' ) };
t = table( 'Size', horzcat( 1, 1 ), 'VariableNames', varName, 'VariableTypes', { 'double' } )
% Example 2: multi-line char array.
varName = char( 'A multi-', 'line name' );
t = table( 'Size', horzcat( 1, 1 ), 'VariableNames', varName, 'VariableTypes', { 'double' } )

Accepted Answer

Sean de Wolski
Sean de Wolski on 21 Jul 2021
t = table(1,'VariableNames',"hello"+newline+"world")
t = table
hello↵world ___________ 1
t(1, "hello"+newline+"world")
ans = table
hello↵world ___________ 1
Not sure why you'd want this though?
  2 Comments
Walter Roberson
Walter Roberson on 21 Jul 2021
It is not possible with any built-in functionality in any released version.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by