struct2table display 1 x l arrays compactly
Afficher commentaires plus anciens
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 commentaire
Is there something you do differently ?
S.a = rand(1,100);
B = struct2table(S)
B{1,:}
Réponses (1)
Star Strider
le 9 Mar 2026 à 15:07
Modifié(e) : Star Strider
le 9 Mar 2026 à 15:36
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.
.
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!