- #1
Odysseo
- 3
- 1
Hallo, this is my first thread here. I have to do a double loop.
I've a 1x4 cell containing 4 sources. For each of this sources i have a number of dataset labeled as source_pN where N is a number (a label for a group). I have to do a double "for" loop on sources and on each existing N to create another dataset with histc on previous dataset variables. So i would like to name those new datasets using both source name and N number. I've done something like this:
But it doesn't work. How can i solve my problem? Any hints?
I've a 1x4 cell containing 4 sources. For each of this sources i have a number of dataset labeled as source_pN where N is a number (a label for a group). I have to do a double "for" loop on sources and on each existing N to create another dataset with histc on previous dataset variables. So i would like to name those new datasets using both source name and N number. I've done something like this:
Matlab:
sources = {'BKG' 'Ba133' 'Co57' 'Cs137'};
for is = 1:length(sources)
sourcename = sources{is};
source = eval(sprintf('%spixels', sourcename));
source.groups = source.nx*100+source.ny;
for grp = 1:length(unique(source.groups))
pix = source.groups(grp);
if -SOMETHING TO CHECK WHICH N-
data = eval(sprintf('%s_P%i',sourcename,pix));
Qbins.data = 0:0.05:max(data.Qnet);
Qpop.data = histc(data.Qnet, Qbins.data);
else
continue
end
end
end
Last edited by a moderator: