Unequivalent loop structure in MATLab -


i have 2 versions of code - wrote second (more explicit) loop when first didn't wanted.

where did go wrong? suspect slicing problem (as in, i'm not correctly slicing data out)

the first version, doesn't want, commented out above loop:

rbool = false(h.numdirs, h.numtimes, h.numr); d = 1:h.numdirs     u_first = h.data(d,1,:);     u_first = u_first{1};     t = 2:h.numtimes         u = h.data(d,t,:);         u = u{1};         du = abs(u-u_first);         %rbool(d,t,:) = (du > (smallval*u_first) | rbool(d,t-1));         r=1:h.numr             rbool(d,t,r) = (du(r) > (smallval*u_first(r))| rbool(d,t-1,r));         end     end end     

you missing third index of second rbool in commented line:

rbool(d,t,:) = (du > (smallval*u_first) | rbool(d,t-1,:)); 

although i'd parenthesize this:

rbool(d,t,:) = (du > (smallval*u_first)) | rbool(d,t-1,:); 

the version had implicitly assumed r==1, think.

and can simplify code setting

u = h.data{d,t,1}; 

instead of cutting out cell vector , choosing first element.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -