MATLAB: Error using ==> rdivide

rdivide

For
w = randn(10, 51300);
w = w./ sum(w,1);
i get
??? Error using ==> rdivide
Matrix dimensions must agree.
For each column of 10 elements, I wish to divide each element by sum(w,1).
How can I do this without using a for loop? thanks

Best Answer

Use the bsxfun() function:
>> w = bsxfun(@rdivide,w,sum(w,1));