how to find norm of each vector in one matric in Matlab?

1 回表示 (過去 30 日間)
ha ha
ha ha 2017 年 11 月 2 日
回答済み: Steven Lord 2017 年 11 月 2 日
Let's say:
Matrix A=[3 2 1 %vector 1
1 1 1] %vector 2
How to find norm of each vector of matrix A? I hope the result will same as follow:
output= [sqrt(14) <---- norm(vector1)= sqrt(14)
sqrt(3) ] <---- norm(vector2)= sqrt(3)
output= [ 3.74
1.73 ]
I know if we use the syntax "norm", so we can find the norm of each vector. But if I use: norm(A), the result is NOT same as my expectation

採用された回答

KL
KL 2017 年 11 月 2 日
sqrt(sum(A.^2,2))

その他の回答 (2 件)

Steven Lord
Steven Lord 2017 年 11 月 2 日
If you're using release R2017b or later, use vecnorm with both the norm (p) and dimension (dim) optional inputs.

Jan
Jan 2017 年 11 月 2 日

カテゴリ

Help Center および File Exchange線形代数 についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!