Operate on all the columns of a matrix

조회 수: 2 (최근 30일)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020년 4월 30일
답변: Sindar 2020년 4월 30일
I have a 100*3 matrix and want to normalize each column. Sth like this:
for i=1:3
norm=normalize(mat(:,i))
end
Is there any shorter way to remove "for loop"? This matrix is part of a code that changes its columns in each simulation.

채택된 답변

Sindar
Sindar 2020년 4월 30일
"N = normalize(A,dim) returns the z-score along dimension dim. For example, normalize(A,2) normalizes each row."
norm_mat=normalize(mat,1);
norm is a function, so I don't recommend using it as a variable name

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by