Given a vector containing values 1 through 1000, I would like to multiply the vector elements by constant C1 if they range from 1-100, by constant C2 if they range from 100-200, etc…
Is there a simpler way to do this than iterating through the vector?
for i = 1:size(vector,2); if vector(i) < 100 C = C1; else if vector(i) < 200 C = C2; end result(i) = vector(i) * C;end
Best Answer