I have a following problem - I have a matrix A
of size 16x22440.
What I need to do is to normalize each row of this matrix, so that the norm of each of them is equal to 1 (for n=1:16 norm(A(n,:))==1
)
How can I achieve that in matlab?
Edit: Each row in this matrix is a vector created of an 160x140 image and thus must be considered separately. The values need to be normalised to create an eigenfaces matrix.
First, compute the norm (I assume Eucleadian norm here)
n = sqrt( sum( A.^2, 2 ) );
% patch to overcome rows with zero norm
n( n == 0 ) = 1;
nA = bsxfun( @rdivide, A, n ); % divide by norm