Is it possible to replace 4 for loops in the form: for if for for if for if …. ….
with something that is more efficient?
because some of the data i run have millions of variables, and i have lots of data set to run, it takes a few days to finish them. So anything that would lower the run time of this section would be geatly appreciated. Thanks
[EDITED: Code yopied form the comments, Jan Simon]
for i=1:length(starts) counter = 0; if isempty(starts{i}) == 0 for j = 1: length(starts{i}) for k = 1: length(starts) if isempty(starts{k}) ==0 for m = 1:length (starts{k}) if stops{i}(j) >= starts{k}(m) && stops{i}(j)< stops{k}(m) && isempty(peak_loc3{k})==0 && peak_loc3{i}(j)~= peak_loc3{k}(m) counter = counter +1; overlap{1,i}(counter) = peak_loc3{k}(m); overlap{2,i}(counter) = peak_loc3{i}(j); end end end end end endend
Best Answer