Nested structure

10 visualizzazioni (ultimi 30 giorni)
Ganesh
Ganesh il 18 Mag 2011
I am interested in reading data from a field of a structure which is within many layers of structures. data = info.ROIcontour1.Slice1.contourdata; This fetches the contourdata from slice#1 of the first ROI. I would like to read all the slices of that ROI and store inside 'data'. Obviously, doing this manually for 100s of slices is not fun. I am not aware of a solution using a simple For loop. Suggest me ways.
Thanks, Ganesh

Risposta accettata

Walter Roberson
Walter Roberson il 18 Mag 2011
fn = fieldnames(info.ROIcontour1);
fn = fn(strncmp(fn,'Slice',5));
nf = length(fn);
contourslices = cell(nf,1);
for K = 1 : nf
countourslices{K} = info.ROIcontour1.(fn{K}).contourdata;
end

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by