MATLAB: Change the element-by-element organization into a plane organization

element by elementorganizationplanestructstructure

Hello
I have an array <20000×1 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

Best Answer

long time ago I found my own solution but forgot to put it here. So, here it is:
folder = ['/scratch ...']
fields = fieldnames (datastructold) ;
for f = 1:size(fields,1) ;
varname = genvarname(fields{f}) ;
extract = {datastructold.(varname)};
datastructnew.(varname) = extract ;
end
v = genvarname([ 'name' ]) % name for variable
S.(v) = datastructnew
save([ folder v '.mat' ] , '-struct' , 'S' ) ; % name for .mat