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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by