While loop Vectorization
问题 I would like to know if there is some way to vectorize this code. I tried so hard to do it... but failed. while (delta_F > e) && (i < maxLoop) x1 = x0+d; y0 = f(x0); y1 = f(x1); if y1 < y0 x0= x1; d = a*d; else vF = [vF;x1]; d = -b*d; end i = i + 1; if length(vF) > 1 ultm = vF(end); pultm = vF(end-1); delta_F = abs(ultm+pultm)/2; end end It's a simple implementation of the Rosenbrock method for finding the min of a function. 回答1: In general, Matlab's vectorization works over fixed-size arrays