% You can also use http://www.cad.zju.edu.cn/home/dengcai/Data/code/NormalizeFea.m.

matlab中对一个矩阵的行（列）归一化为二范数是1的简洁代码：一句实现
%  normalize each row to unit
A = A./max(1e-12,repmat(sqrt(sum(A.^2,2)),1,size(A,2)));% 1e-12 is similar as %http://www.cad.zju.edu.cn/home/dengcai/Data/FaceData.html to avoid the problem that one row of A is zero
%  normalize each column to unit
A = A./max(1e-12,repmat(sqrt(sum(A.^2,1)),size(A,1),1));
% % Nannan wang says that in matlab, cycling(循环) is time-consuming.
% % 能不用循环就不用循环
% % Examples
% A=[3 4;5 12];
% [m n] = size(A);
% % normalize each row to unit
% for i = 1:m
%     A(i,:)=A(i,:)/norm(A(i,:));
% end
% A
% % another beautiful way to normalize each row to unit
% A=[3 4;5 12];
% A = A./repmat(sqrt(sum(A.^2,2)),1,size(A,2));
% A
% % normalize each column to unit
% A=[3 4;5 12];
% for i = 1:n
%     A(:,i)=A(:,i)/norm(A(:,i));
% end
% A
% % another beautiful way to normalize each column to unit
% A=[3 4;5 12];
% A = A./repmat(sqrt(sum(A.^2,1)),size(A,1),1);
% A