change the element-by-element organization into a plane organization
Mostra commenti meno recenti
Hello
I have an array <20000x1 struct> in element-by-element organization. Each of the 20000 entries has more than 30 fields.
I would like to change the element-by-element organization into a plane organization.
I found how to do it from plane to element-by-element ( http://www.mathworks.com/matlabcentral/answers/4581-deleting-the-i-th-entry-from-all-fields-of-a-struct) but I cannot figure out how to do it in the opposite way.
Could you help me, please?
Thank you very much
Claudia
1 Commento
Claudia
il 8 Nov 2012
Risposta accettata
Più risposte (2)
Walter Roberson
il 15 Mag 2012
0 voti
struct2cell(), then either cell2mat() or expand the cell within a vertcat() or horzcat().
However, if the fields are not all exactly the same size or are of mixed numeric type involving more than one integer data type, then you are going to have problems.
1 Commento
Claudia
il 18 Mag 2012
Sean de Wolski
il 8 Nov 2012
Modificato: Sean de Wolski
il 8 Nov 2012
So if this is a simple example of your struct:
S = struct('field1',num2cell(1:10),'field2',num2cell(repmat(pi,1,10)))
Then I would recommend using:
S2 = squeeze(struct2cell(S))
To now have a 2x10 cell array.
Categorie
Scopri di più su Structures in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!