Nested structure

조회 수: 10 (최근 30일)
Ganesh
Ganesh 2011년 5월 18일
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

채택된 답변

Walter Roberson
Walter Roberson 2011년 5월 18일
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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by