Watch this Author's files
could be solved more efficiently by calling bsxfun...
A = magic(4); An = bsxfun(@rdivide,A,sum(A,2));
Contact us at files@mathworks.com