Displaying MATLAB tables wrapped

14 Ansichten (letzte 30 Tage)
Dan
Dan am 30 Jun. 2023
Kommentiert: dpb am 5 Jul. 2023
I only starting using the MATLAB datatype, table, a few years ago but have always been annoyed that when I display a table in MATLAB, if you have many fields, the display runs off the right side of the command window display and you have to scroll right to see other columns (other fields). I recently had to step back to MATLAB 2014 in a specific setting and starting using tables in that envronment as well. The function, head did not exist back then but I could do something similar with:
disp(TBL(1:6,:));
And wouldn't you know it,the display actually wrapped at the end of the command window such that I did not have to scroll to the right to see what I needed ... I only needed to scroll up and down. With no success, I have searched and searched the settings for a switch to make table display wrap. Does anyone know if there is a setting that wraps table display? Thanks, Dan
  3 Kommentare
Catalytic
Catalytic am 3 Jul. 2023
Why is scrolling up and down better than scrolling left to right? Generally, computer monitors are wider than they are tall, so you will have to do more up-down scrolling for wrapped output than unwrapped.
Dan
Dan am 3 Jul. 2023
Given the wrapped display, with a limited number of rows shown, i can survey far more variables simultaneously with the wrapped display format (see Matt J's response below for an example of a wrapped display).

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 30 Jun. 2023
Bearbeitet: Matt J am 30 Jun. 2023
One possibility,
TBL=array2table(rand(4,12));
wrapit(TBL)
Var1 Var2 Var3 Var4 Var5 Var6 Var7 _______ _______ _______ ________ _______ _______ ________ 0.79956 0.92891 0.75922 0.021847 0.42395 0.84367 0.94405 0.63505 0.18978 0.26817 0.51076 0.10941 0.4028 0.068908 0.11504 0.61899 0.22835 0.75201 0.89684 0.64857 0.47912 0.18127 0.16373 0.89018 0.89885 0.63307 0.54857 0.63189 Var8 Var9 Var10 Var11 Var12 ________ ________ ________ _______ _______ 0.033257 0.46148 0.22872 0.98722 0.50879 0.077581 0.92888 0.7676 0.35275 0.87881 0.37961 0.54332 0.7974 0.68836 0.21009 0.57671 0.061872 0.015807 0.2225 0.42195
function wrapit(T,ncols)
if nargin<2, ncols=7; end
M=ceil(width(T)/ncols);
for i=1:M
k=min(ncols,width(T));
t=T(:,1:k); T(:,1:k)=[];
disp(t)
end
end
  2 Kommentare
Dan
Dan am 3 Jul. 2023
Thanks, MattJ, a good first cut ... but given the dynamic nature of all the different datatypes, especially tables within tables, which I do use, I'm not sure how useful this will be. I hope the Mathworks will consider going back to the old display option as a preference.
dpb
dpb am 5 Jul. 2023
It (disp) will adhere to the global Preferences setting for "Wrap Variables", but it wraps every line of the table rather than keeping rows together so they intermix...

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by