Working with structures : Unrecognized field name
Mostrar comentarios más antiguos
Hello everyone,
I'm starting to work with Structure array variables and I'm stuck for their use in my function.
I want to get the name of a field in order to use it in a dot product to get data that I use to make my calculations.
So if we take the following example:
s.a.b={'A', 'B', 'C'};
s.a.data={0.125, 0.02, 0, 0, 5, 958, 5.6};
In my case, it is necessary to consider that I obtain the structure "s" without knowing the name of the first field "a", but all other field are known (I work with several sets of structures, this field "a" represents a name that will be different each time for each structure, unlike other fields). The data I need are in the "data" field. So I need to find the name of this field ("a") in order to recover my data by dot product.
I tried to automate the field name search via the "fieldnames()" function, but the result cannot be used in a dot product as I would like.
Field=fieldnames(s);
Dat=s.Field.data
Do you have any ideas on how to get around this problem?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Structures en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!