how to get the specific member data from a struct array?
Afficher commentaires plus anciens
for example,
b=struct('name','JPEG','age','18') ;
c=repmat(b,3,1) ;
d=c.name;
c.name
why is the result of "c.name" different from the result of "d=c.name"?
how to get the member data directly from a struct array or matrix? such as c.name?
and another question, how to create a struct array or matrix directly just like zeros(2,3), but struct(2,3) doesn't work, so how?
Réponse acceptée
Plus de réponses (1)
Alexandra Harkai
le 4 Nov 2016
Modifié(e) : Alexandra Harkai
le 4 Nov 2016
0 votes
What c is is what is called a nonscalar struct array. Then "You cannot assign the list to a single variable with the syntax v = s.f because the fields can contain different types of data." as per the Documentation, so variable d gets only c(1).name, and hence they will be different.
2 commentaires
Alexandra Harkai
le 7 Nov 2016
Please do not change your question once it has been answered, it is preferred to start new one.
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!