Content of table not fully displayed

14 views (last 30 days)
Dennis
Dennis on 13 Jul 2023
Commented: Dennis on 13 Jul 2023
Hi, I'm currently trying to finish my master thesis over the summer but I'm running into some problems with processing data in Matlab. I have a table with 401 rows of different measures of sleep durations (see attachment):
I want to export it to Excel with all sleeping times, but the times are stored in one cell, and can only be seen when clicking on the cell:
I want all the sleep durations of each cell being shown in the original table on their respective row, so I can copy all the data all at once to Excel (instead of manually doing it for each row, 401 times). With what code can I change the table so that all datetimes are visible at once? Hope someone knows this, it would help me so much :).

Accepted Answer

Stephen23
Stephen23 on 13 Jul 2023
Edited: Stephen23 on 13 Jul 2023
It is unclear why you are storing a cell array in a table with only one variable... why not just the cell array?
S = load('Sleepduration.mat');
T = S.sleepDurationTable % superfluous table?
T = 401×1 table
SleepDurationH __________________________________________________________________________________________________________________________________________________________________________________________________ {[ 8.2500 7.1000 3.6500 4.8500 8.0500 9.1000 7.6833 6.8667 7.9500 5.6667 6.7500 6.0667 5.9500 7.6000 6.2167 6.7333 6.5500 7.9333 17.8000 9.7667 7.5500 5.8500 10.2000 6.6000 7 7.3333 8.6167 … ]} {[ 6.0667 3.4833 3.9167 4.2667 8.2333 6.5833 5.0667 4.5167 4.0667 5.9000 4.2000 5.4833 4.7667 4.4833 2.5167 5.5167 6.9833 3 5.6500 6.2667 3.2833 3.2333 5.1167 4.3833 5.7167 5.8833 8.8667 … ]} {[ 6.9500 7.5167 8.7500 8.1167 7.5667 8.2833 6.2667 8.3667 11.3000 8.8333 7.4500 8.4000 8.0167 7.6500 7.0167 7.8667 8.2500 6.9667 7.6833 7.4333 5.3500 3.6500 5.8167 7.2833 7.0333 8.4000 … ]} {[ 10.3167 7.4500 4.1500 4.6000 12.2833 11 6.4500 15.6000 4.4667 8.5833 5.4667 12.8667 12.3000 14.8000 2.3833 20.8333 15.0500 8.0667 12.0667 7.0500 4.2667 5.3167 2.0333 3.1167 5.6167 4.6333 … ]} {[ 6.5000 6.9500 5.5500 6.2500 3.9333 6.6500 7.7667 5.6000 2.9833 5.5000 7.5667 7.1500 5.9333 3.7667 4.4000 4.2333 5.5000 3.5833 5.5333 8.3500 7.5000 5.5500 3.4667 6.8500 9.6833 5.7833 9 … ]} {[ 9.9000 4.7667 12.3000 5.7167 9.8167 7.1833 5.7167 11 5.5833 4.3667 12.0833 6.7667 10.2833 13.9833 6.2333 8.0667 3.6833 6.6667 6.4833 7.2667 7.5000 8.0667 8.6500 6 6.5167 6.3000 7.9167 … ]} {[ 7.7667 9.0833 10.4333 7.9333 7.3167 8.5000 6.6000 10.3000 8.4500 6.2000 9.8000 9.3000 9.3500 7.6333 7.8500 5.2500 9.6500 7.8667 8.9167 9.3833 3.4167 9.1667 8.2667 5.1333 8.3000 7.7667 … ]} {[ 7.2167 6.3000 6.6833 6.0667 8.1667 7.7333 5.9500 8.0500 7.4500 13.0500 8.3667 7.2000 7.2167 7.3333 6.5333 4.5667 9.5333 6.4667 7.6667 6.4500 7.3167 7.3833 9.5500 7.7000 7.0333 158.9667 … ]} {[ 9.8833 9.1667 11.2333 9.6000 9.5500 11.7667 9.5667 9.9667 10.1667 12.2167 9.2833 13.1167 10.4333 15.7167 11.1000 9.2000 10.3333 9.0667 9.1500 13.3667 14.7667 9.2500 13.0833 11.8667 … ]} {[ 8.2000 8.4500 7.7833 7.5500 7.7333 7.1833 7.6667 8.2667 7.1167 7.7167 6.2333 8.2667 9.6000 11.2500 3.6833 7.4333 7.2667 7.7333 7.7667 8.6333 8.0333 6.6500 13.2833 6.3333 6.5333 10.3000 … ]} {[ 6.7667 5.4167 8.2667 6.7667 8.9667 8.0833 9.6167 7.2500 7.5833 8.4833 8.0833 7.5167 9.5333 9.7500 8.1500 8.3333 8.5333 7.9500 8.3167 8.4333 6.6833 5.9500 8.5833 7.7000 6.7500 7.4833 … ]} {[ 8.4333 6.7000 7.9333 6.4667 7.2167 9.1667 7.3667 10.6500 8.7667 7.1667 9.3167 8.7833 6.5167 7.3833 7.2500 10.6833 13.1167 7.9667 8.2167 7.9333 7.8500 9.2667 6.3500 8.1667 6.9167 7.4500 … ]} {[ 6.7833 7.2833 7.2167 6.5000 7.9500 7.0333 5.6500 7.4000 6.4333 7.6333 6.3333 6.7000 6.7000 3.2667 3.5167 6.0333 3.3833 6.0833 7.3333 3.0333 7.5333 3.9000 3.8000 6.7167 7.2167 6.6667 … ]} {[ 8.1667 8.0833 7.2833 8.2167 8.2833 11.9167 9.4000 8.8167 8.2833 7.9667 7.4000 8.2333 8.0167 8.8333 7.9667 8.5333 7.5833 7.9667 7.6000 7.8833 7.4333 7.8500 8 7.2500 8.7500 7.0500 7.8500 … ]} {[ 8.1500 7.4333 8.6333 2.8833 6.5333 10.5167 8.9833 9.7667 10.2667 8.4833 10.2333 9.1167 8.7833 9.2667 8.5167 8.8333 9.0667 5.9000 9.3333 9.6667 9 8.6000 9.9500 11.2667 7.6333 9.6500 … ]} {[7.6833 9.5167 10.7500 9 9.0333 8.1000 8.6000 9.2167 9.4167 8.0167 7.1000 6.3667 4.8667 11.9833 8.9833 10.2667 9.5500 10.5667 9.4667 9.8667 8.5500 9.7167 7.2000 8.8500 8.8000 9.6833 6.5500 … ]}
C = T.SleepDurationH
C = 401×1 cell array
{[ 8.2500 7.1000 3.6500 4.8500 8.0500 9.1000 7.6833 6.8667 7.9500 5.6667 6.7500 6.0667 5.9500 7.6000 6.2167 6.7333 6.5500 7.9333 17.8000 9.7667 7.5500 5.8500 10.2000 6.6000 7 7.3333 8.6167 … ]} {[ 6.0667 3.4833 3.9167 4.2667 8.2333 6.5833 5.0667 4.5167 4.0667 5.9000 4.2000 5.4833 4.7667 4.4833 2.5167 5.5167 6.9833 3 5.6500 6.2667 3.2833 3.2333 5.1167 4.3833 5.7167 5.8833 8.8667 … ]} {[ 6.9500 7.5167 8.7500 8.1167 7.5667 8.2833 6.2667 8.3667 11.3000 8.8333 7.4500 8.4000 8.0167 7.6500 7.0167 7.8667 8.2500 6.9667 7.6833 7.4333 5.3500 3.6500 5.8167 7.2833 7.0333 8.4000 … ]} {[ 10.3167 7.4500 4.1500 4.6000 12.2833 11 6.4500 15.6000 4.4667 8.5833 5.4667 12.8667 12.3000 14.8000 2.3833 20.8333 15.0500 8.0667 12.0667 7.0500 4.2667 5.3167 2.0333 3.1167 5.6167 4.6333 … ]} {[ 6.5000 6.9500 5.5500 6.2500 3.9333 6.6500 7.7667 5.6000 2.9833 5.5000 7.5667 7.1500 5.9333 3.7667 4.4000 4.2333 5.5000 3.5833 5.5333 8.3500 7.5000 5.5500 3.4667 6.8500 9.6833 5.7833 9 … ]} {[ 9.9000 4.7667 12.3000 5.7167 9.8167 7.1833 5.7167 11 5.5833 4.3667 12.0833 6.7667 10.2833 13.9833 6.2333 8.0667 3.6833 6.6667 6.4833 7.2667 7.5000 8.0667 8.6500 6 6.5167 6.3000 7.9167 … ]} {[ 7.7667 9.0833 10.4333 7.9333 7.3167 8.5000 6.6000 10.3000 8.4500 6.2000 9.8000 9.3000 9.3500 7.6333 7.8500 5.2500 9.6500 7.8667 8.9167 9.3833 3.4167 9.1667 8.2667 5.1333 8.3000 7.7667 … ]} {[ 7.2167 6.3000 6.6833 6.0667 8.1667 7.7333 5.9500 8.0500 7.4500 13.0500 8.3667 7.2000 7.2167 7.3333 6.5333 4.5667 9.5333 6.4667 7.6667 6.4500 7.3167 7.3833 9.5500 7.7000 7.0333 158.9667 … ]} {[ 9.8833 9.1667 11.2333 9.6000 9.5500 11.7667 9.5667 9.9667 10.1667 12.2167 9.2833 13.1167 10.4333 15.7167 11.1000 9.2000 10.3333 9.0667 9.1500 13.3667 14.7667 9.2500 13.0833 11.8667 … ]} {[ 8.2000 8.4500 7.7833 7.5500 7.7333 7.1833 7.6667 8.2667 7.1167 7.7167 6.2333 8.2667 9.6000 11.2500 3.6833 7.4333 7.2667 7.7333 7.7667 8.6333 8.0333 6.6500 13.2833 6.3333 6.5333 10.3000 … ]} {[ 6.7667 5.4167 8.2667 6.7667 8.9667 8.0833 9.6167 7.2500 7.5833 8.4833 8.0833 7.5167 9.5333 9.7500 8.1500 8.3333 8.5333 7.9500 8.3167 8.4333 6.6833 5.9500 8.5833 7.7000 6.7500 7.4833 … ]} {[ 8.4333 6.7000 7.9333 6.4667 7.2167 9.1667 7.3667 10.6500 8.7667 7.1667 9.3167 8.7833 6.5167 7.3833 7.2500 10.6833 13.1167 7.9667 8.2167 7.9333 7.8500 9.2667 6.3500 8.1667 6.9167 7.4500 … ]} {[ 6.7833 7.2833 7.2167 6.5000 7.9500 7.0333 5.6500 7.4000 6.4333 7.6333 6.3333 6.7000 6.7000 3.2667 3.5167 6.0333 3.3833 6.0833 7.3333 3.0333 7.5333 3.9000 3.8000 6.7167 7.2167 6.6667 … ]} {[ 8.1667 8.0833 7.2833 8.2167 8.2833 11.9167 9.4000 8.8167 8.2833 7.9667 7.4000 8.2333 8.0167 8.8333 7.9667 8.5333 7.5833 7.9667 7.6000 7.8833 7.4333 7.8500 8 7.2500 8.7500 7.0500 7.8500 … ]} {[ 8.1500 7.4333 8.6333 2.8833 6.5333 10.5167 8.9833 9.7667 10.2667 8.4833 10.2333 9.1167 8.7833 9.2667 8.5167 8.8333 9.0667 5.9000 9.3333 9.6667 9 8.6000 9.9500 11.2667 7.6333 9.6500 … ]} {[7.6833 9.5167 10.7500 9 9.0333 8.1000 8.6000 9.2167 9.4167 8.0167 7.1000 6.3667 4.8667 11.9833 8.9833 10.2667 9.5500 10.5667 9.4667 9.8667 8.5500 9.7167 7.2000 8.8500 8.8000 9.6833 6.5500 … ]}
L = cellfun(@numel,C);
M = NaN(numel(C),max(L));
for k = 1:numel(C)
M(k,1:L(k)) = C{k};
end
display(M) % optional
M = 401×1187
8.2500 7.1000 3.6500 4.8500 8.0500 9.1000 7.6833 6.8667 7.9500 5.6667 6.7500 6.0667 5.9500 7.6000 6.2167 6.7333 6.5500 7.9333 17.8000 9.7667 7.5500 5.8500 10.2000 6.6000 7.0000 7.3333 8.6167 8.3000 4.5000 6.1500 6.0667 3.4833 3.9167 4.2667 8.2333 6.5833 5.0667 4.5167 4.0667 5.9000 4.2000 5.4833 4.7667 4.4833 2.5167 5.5167 6.9833 3.0000 5.6500 6.2667 3.2833 3.2333 5.1167 4.3833 5.7167 5.8833 8.8667 3.1500 4.9833 2.9667 6.9500 7.5167 8.7500 8.1167 7.5667 8.2833 6.2667 8.3667 11.3000 8.8333 7.4500 8.4000 8.0167 7.6500 7.0167 7.8667 8.2500 6.9667 7.6833 7.4333 5.3500 3.6500 5.8167 7.2833 7.0333 8.4000 8.5000 7.4000 7.0833 7.6500 10.3167 7.4500 4.1500 4.6000 12.2833 11.0000 6.4500 15.6000 4.4667 8.5833 5.4667 12.8667 12.3000 14.8000 2.3833 20.8333 15.0500 8.0667 12.0667 7.0500 4.2667 5.3167 2.0333 3.1167 5.6167 4.6333 3.4500 2.9833 4.9000 6.2833 6.5000 6.9500 5.5500 6.2500 3.9333 6.6500 7.7667 5.6000 2.9833 5.5000 7.5667 7.1500 5.9333 3.7667 4.4000 4.2333 5.5000 3.5833 5.5333 8.3500 7.5000 5.5500 3.4667 6.8500 9.6833 5.7833 9.0000 6.1667 6.5667 7.9167 9.9000 4.7667 12.3000 5.7167 9.8167 7.1833 5.7167 11.0000 5.5833 4.3667 12.0833 6.7667 10.2833 13.9833 6.2333 8.0667 3.6833 6.6667 6.4833 7.2667 7.5000 8.0667 8.6500 6.0000 6.5167 6.3000 7.9167 11.0833 2.7333 10.1500 7.7667 9.0833 10.4333 7.9333 7.3167 8.5000 6.6000 10.3000 8.4500 6.2000 9.8000 9.3000 9.3500 7.6333 7.8500 5.2500 9.6500 7.8667 8.9167 9.3833 3.4167 9.1667 8.2667 5.1333 8.3000 7.7667 8.3833 7.4000 7.8500 7.6333 7.2167 6.3000 6.6833 6.0667 8.1667 7.7333 5.9500 8.0500 7.4500 13.0500 8.3667 7.2000 7.2167 7.3333 6.5333 4.5667 9.5333 6.4667 7.6667 6.4500 7.3167 7.3833 9.5500 7.7000 7.0333 158.9667 7.6500 8.1667 6.1167 7.3667 9.8833 9.1667 11.2333 9.6000 9.5500 11.7667 9.5667 9.9667 10.1667 12.2167 9.2833 13.1167 10.4333 15.7167 11.1000 9.2000 10.3333 9.0667 9.1500 13.3667 14.7667 9.2500 13.0833 11.8667 11.0167 10.8833 11.5667 10.6000 9.0500 10.4833 8.2000 8.4500 7.7833 7.5500 7.7333 7.1833 7.6667 8.2667 7.1167 7.7167 6.2333 8.2667 9.6000 11.2500 3.6833 7.4333 7.2667 7.7333 7.7667 8.6333 8.0333 6.6500 13.2833 6.3333 6.5333 10.3000 8.3000 5.0667 6.2667 7.5000
writematrix(M,'test.xlsx') % much better than copy-and-paste
You could also use Jos's convenient PADCAT:
M = padcat(C{:});
writematrix(M,'test.xlsx')
  1 Comment
Dennis
Dennis on 13 Jul 2023
Once again thank you so much! This was al the data processing I needed for my thesis in Matlab. You are a real lifesaver :). And I have no idea why the data is stored like this, this is how I received it from my professor.

Sign in to comment.

More Answers (1)

Sahaj
Sahaj on 13 Jul 2023
Hi Dennis.
I do not think there is a workaround for viewing the contents of the table, since each cell variable is made up of many cell variables. However, instead of wanting to copy all the data at once, you can take help of the writetable(table, filename) function in matalb to export your table to an excel file with the name filename.
Hope this helps.
  3 Comments
Sahaj
Sahaj on 13 Jul 2023
Did you try the same workflow? There just seems to be a difference in the datatype.
Dennis
Dennis on 13 Jul 2023
Yes, but I am too inexperienced in coding to make it work sadly :(

Sign in to comment.

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!