table2struct
Convertir une table en tableau de structures
📝 Syntaxe
S = table2struct(T)
S = table2struct(T, "ToScalar", true)
📥 Argument d'entrée
T - un objet table
📤 Argument de sortie
S - Structure.
📄 Description
S = table2struct(T) convertit la tableT en un tableau de structures S, où chaque variable deT est représentée comme un champ dans S.
Si T est une table m-by-n,S sera un tableau de structures m-by-1 avec n champs.
La sortieS ne contiendra pas les propriétés de table provenant deT.Properties.
S = table2struct(T, "ToScalar", true) convertit la tableT en une structure scalaire S, où chaque variable deT devient un champ dans S.
Si T est une table m-by-n,S contiendra n champs, et chaque champ aura m lignes.
💡 Exemple
Names = {'John'; 'Alice'; 'Bob'; 'Diana'};
Age = [28; 34; 22; 30];
Height = [175; 160; 180; 165];
Weight = [70; 55; 80; 60];
T = table(Names, Age, Height, Weight)
S1 = table2struct(T)
S1 = table2struct(T, "ToScalar", true)🔗 Voir aussi
🕔 Historique
Version
📄 Description
1.8.0
version initiale
Last updated
Was this helpful?