How do I name elements in a field of a structure?
Show older comments
I have a 1*1 structure with 4 fields. The structure was generated from anova1 so I didn't create it. One field is 33 *2 and I want to name each integer place with a string but I cannot seem to do this. Can anyone help?
Thanks! Kim
3 Comments
Image Analyst
on 18 Mar 2013
Please show us what this says
yourStructure
whos yourStructure
so we know what it is. I don't understand. Do you want 66 variables, each with a different name that represent each of the 66 elements in your 33 by 2 array that is one of your structure fields???
Kim
on 18 Mar 2013
Edited: Walter Roberson
on 18 Mar 2013
Walter Roberson
on 18 Mar 2013
Okay, now what is it you want to do with the information?
It appears to me that if you want to know the group name for the group whose mean is st.means(K) then you would find it at st.gnames(K,:)
Accepted Answer
More Answers (1)
Walter Roberson
on 18 Mar 2013
I'm not sure what you mean by naming each integer place with a string?
You can use
Structurename.appropriate_fieldname(I,J)
to access at matrix location (I,J) of the field. You can use
fieldnames(Structurename)
to find out what the field names are.
You cannot, however, do something like say that you want the variable "PLU" to refer to column 1 of the field -- not without extracting it from the structure.
If you need to be able to say things like "PLU(5) = 142031" and have it affect the contents of the structure field, then you need to use a "dataset", which I seem to recall is part of the Stats toolbox.
3 Comments
Kim
on 18 Mar 2013
Kim
on 18 Mar 2013
Image Analyst
on 18 Mar 2013
I see you accepted Azzi's answer. So is this all solved now?
Categories
Find more on Repeated Measures and MANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!