How do I display a Table on Command Window?
1.063 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Trying to display something like this:
Name A B C D
--------------------------------
Min 1 2 3 4
Max 5 6 7 8
Any Ideas?
1 comentario
Adam Danz
el 13 de Abr. de 2021
@zaianb almahdi, are you having trouble displaying the table using disp(T)? Your comment is not clear.
Respuestas (1)
Adam Danz
el 22 de En. de 2020
Editada: Adam Danz
el 24 de En. de 2020
Here are two methods that produce that table. The first defines each column of the table. The second converts the matrix into a table.
% Method 1: Define each column
T = table([1;5],[2;6],[3;7],[4;8],'VariableNames',{'A','B','C','D'},'RowName',{'Min','Max'});
% Method 2: convert matrix
T = array2table([1:4;5:8],'VariableNames',{'A','B','C','D'},'RowName',{'Min','Max'});
% Display table
disp(T)
More info and practice:
10 comentarios
Walter Roberson
el 1 de Dic. de 2023
Testing with MATLAB Answers (which should be the same as LiveScript)
I added comments about what I observe while in original composition mode. The saved message may show up differently; I will comment afterwards on any difference in the saved message.
T = array2table((1:123).');
fprintf('first trying with just variable name\n');
T
%Answers while composing: first 16 rows appeared then . . . and no scroll
fprintf('now trying with disp()\n');
disp(T)
%Answers while composing: first 12 rows visible, scroll to see rest
fprintf('now trying with display()\n');
display(T)
%Answers while composing: first 16 rows appeared then . . . and no scroll
fprintf('now trying with displayWholeObj\n');
displayWholeObj(T, 'T')
%Answers while composing: first 8 rows visible, scroll to see rest
fprintf('done\n');
Walter Roberson
el 1 de Dic. de 2023
first trying with just variable name
Answers while viewing: first 10 rows appeared with a scroll that allowed seeing the first 16 rows and then . . .
now trying with disp()
Answers while viewing: first 11 rows appeared with a scroll that allowed seeing the entire table
now trying with display()
Answers while viewing: first 10 rows appeared with a scroll that allowed seeing the first 16 rows and then . . .
now trying with displayWholeObj
Answers while viewing: first 7 rows appeared with a scroll that allowed seeing the entire table
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!