getfield() error when calling on multiple fields: "Struct contents reference from a non-struct array object"
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
camilo sanchez
am 25 Jan. 2018
Kommentiert: Walter Roberson
am 26 Jan. 2018
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!
2 Kommentare
Brandon Madsen
am 25 Jan. 2018
This function is genuinely buggy and does not work as advertised. You can pull up the code and fix it manually for your machine though, since the code for this function is accessible. I can show you how later if you need help.
Akzeptierte Antwort
Nicolas Schmit
am 26 Jan. 2018
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.
2 Kommentare
Walter Roberson
am 26 Jan. 2018
Look at the examples and observe that specifying multiple field names is used to access nested values.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu JSON Format finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!