convert array in a struct
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
elisa ewin
le 20 Mar 2017
Modifié(e) : Greg Dionne
le 20 Mar 2017
Hi,
I want to trasform the array in the file attached in a struct; I have used cell2struct but it doesn't run: can you help me?
0 commentaires
Réponse acceptée
Greg Dionne
le 20 Mar 2017
Modifié(e) : Greg Dionne
le 20 Mar 2017
You didn't give us the fieldnames you wanted. So I'm going to guess you want them as 'thing1', 'thing2', 'thing3', etc. and assign the name in a loop. You can substitute your desired fieldname instead of these.
for i=1:length(Cluster_split)
myValue = Cluster_split{i};
myFieldname = ['thing' num2str(i)];
myStruct.(myFieldname) = myValue;
end
You can now inspect the structure:
myStruct.thing1
myStruct.thing23
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!