matlab - Replacing the colon operator with an equivalent vectorizable solution -
my current code this:
for offset = 0:0.9:max_offset : x = offset:step_size:max_value; [...] end i vectorize , remove loop create faster, if seek making offset vector, colon operator on sec line equivalent doing
x = offset(1):step_size:max_value; what efficient way accomplish desired result, i.e. get
x = [ 0:step_size:max_value; 0.9:step_size:max_value; 1.8:step_size:max_value; ... ] assuming don't know max_offset, , hence length of number of rows want in x?
since each vector different size, wont fit in matrix easily. have set them in cell array, so:
offset=0:.9:max_offset; x=arrayfun(@(k) k:step_size:max_value,offset,'uniformoutput',false) and rather referring rows of x x(i,:) matrix, x{i} right vector out.
matlab octave
No comments:
Post a Comment