struct2table display 1 x l arrays compactly
Show older comments
I have a struct with fields containing all kinds of classes (strings, structs, doubles). I want to convert it to a table using struct2table however the fields that contain 1x100 doubles now show as 100 subcells instead of one compact cell.
what I got:

what i want (but as a table rather than struct)

I know this is pretty much only visual but its still annoying. Is there a way to change the display of these fields?
1 Comment
Is there something you do differently ?
S.a = rand(1,100);
B = struct2table(S)
B{1,:}
Answers (1)
Star Strider
ongeveer 8 uur ago
Edited: Star Strider
ongeveer 7 uur ago
It apparently exists in your structure as a row vector. You will need to convert it to a column vector by transposing it, first.
Try something like this --
S.power_mech = rand(1,10)
T1 = struct2table(S)
S.power_mech = S.power_mech(:) % Transpose (Simple Transpose)
T2 = struct2table(S)
.
EDIT -- (9 Mar 2026 at 15:35)
Format tweak.
.
Categories
Find more on Structures 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!