I have looked for the proper way to access a given field of a struct and the manual and online searches didn't help.
Formally, let MyStruct
be a 1xn struct
variable. It's easy to list all the elements stored in a field with:
MyStruct.Thisfield
ans =
0.7010
ans =
0.310
ans =
0.444
etc.
Now the only way I found to be able to access an element of this is to use a temporary variable, e.g. temp={MyStruct.Thisfield}
and then temp{1,2}
etc. I think it's clumsy but can't figure out what else to do.
This:
>> MyStruct{1,1}.Thisfield
Cell contents reference from a non-cell array object.
and this:
>> MyStruct.Thisfield{1,1}
Field reference for multiple structure elements that is followed by more reference blocks is an error.
are my unsuccessful attempts.
See an example in situ in this answer of mine https://stackoverflow.com/a/22813577/2777181