MATLAB: Getfield() error when calling on multiple fields: “Struct contents reference from a non-struct array object”

getfieldMATLABmultiple field access

Hello,
I have searched around for a good couple of hours but I cannot figure out how to properly use getfield() to call on multiple fields.
What works:
getfield(MyStruct(8), 'field1')
or
getfield(MyStruct(8), 'field2')
Whwat does NOT work:
getfield(MyStruct(8), 'field1', 'field2')
Among many other variations… I have tried specific indexing, so on and so forth. MyStruct is a 1X44 with 10 fields.
Thanks in advance!

Best Answer

Which version of MATLAB are you using? The documentation says that getfield() can access nested fields, not that you can retrieve multiple fields at a time.