# MATLAB: Vectorization of for loop

for loopnestedvectorize

Hi,
I made a 2d matrix with two for loops:
for k = 1:32for l = 1:32P_new(l,k) = P_old(l) + (LODF(l,k) * P_old(k));endend
P_old is here a 32 x 1 matrix and LODF is a 32 x 32 matrix which is already computed. How can I vectorize this code to avoid the for loops? Thanks in advance.

•  P_new= bsxfun(@times, LODF, P_old.'); P_new= bsxfun(@plus, P_new,P_old);