convert from myStruct(index).Log{index2}.ID to myStruct(index).Log.ID(index2)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi people,
I'm having some trouble with cell arrays and structures.
I have the following cell array within a structure:
myStruct(index).Log{index2}.ID
Log is a cell array and it has different lengths for different "index"
I need to remove the cell array and get only structs, like this:
myStruct(index).Log.ID(index2)
In this way, I can do the following:
my_IDs = myStruct(1:2).Log.ID
Is there a way to convert it? Thank you
0 Kommentare
Antworten (1)
Walter Roberson
am 8 Nov. 2011
Something like this might work:
newstruct = arrayfun( @(Sidx) struct('Log', struct('ID', cellfun(@(S) S.ID, myStruct(Sidx).Log) )), 1:length(myStruct) );
I think I unpeeled all the parts correctly, but I do not promise.
0 Kommentare
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!