Assign an array of structs to a cell
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jerry Olup
am 16 Nov. 2017
Kommentiert: Jerry Olup
am 17 Nov. 2017
Hi, I have a variable sized array of structs that I read and want to assign to cell within a cell array. I found a results for "Conversion to cell from struct is not possible." in prior questions but that maps a single struct to a single cell. I would like to be able to store an array of structs to a cell. Is that possible? How? Thanks, Jerry
7 Kommentare
Stephen23
am 17 Nov. 2017
Bearbeitet: Stephen23
am 17 Nov. 2017
"However I am trying to assign an array of structures to a single cell."
I still do not see what the problem is. Any variable can be allocated to a cell, the fact your structure is non-scalar is irrelevant. Here is a non-scalar structure array being allocated to a cell:
>> S(1).data = 1;
>> S(2).data = 3;
>> C{1} = S;
That test code throws no errors, no problems doing exactly what you state: "assign an array of structures to a single cell."
"Instead I hav to access each structure through dot indexing"
You put the data into an structure yourself! How else would you expect to access it?
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!