【 MATLAB 】norm ( Vector and matrix norms )(向量范数以及矩阵范数)
【摘要】 norm
Vector and matrix norms
Syntax
n = norm(v)
n = norm(v,p)
n = norm(X)
n = norm(X,p)
n = norm(X,'fro')
Description
n = norm(v)返回向量v的欧几里德范数。该范数也称为2范数,向量幅度或欧几里德长度。
n = norm(v,p...
norm
Vector and matrix norms
Syntax
n = norm(v)
n = norm(v,p)
n = norm(X)
n = norm(X,p)
n = norm(X,'fro')
Description
n = norm(v)返回向量v的欧几里德范数。该范数也称为2范数,向量幅度或欧几里德长度。
n = norm(X)返回矩阵X的2范数或最大奇异值,其近似为max(svd(X))。
n = norm(X,p)返回矩阵X的p范数,其中p为1,2或Inf:
-
如果p = 1,则n是矩阵的最大绝对列和。
-
如果p = 2,则n近似为max(svd(X))。 这相当于norm(X)。
-
如果p = Inf,那么n是矩阵的最大绝对行和。
n = norm(X,'fro')返回矩阵X的Frobenius范数。
有关范数的基础知识,见博文:【 MATLAB 】范数的必备基础知识
下面举例说明:
Vector Magnitude(向量幅度)
-
%Create a vector and calculate the magnitude.
-
-
v = [1 -2 3];
-
n = norm(v)
-
% n = 3.7417
1-Norm of Vector
-
clc
-
clear
-
close all
-
-
% Calculate the 1-norm of a vector, which is the sum of the element magnitudes.
-
-
X = [-2 3 -1];
-
n = norm(X,1)
-
% n = 6
Euclidean Distance Between Two Points
-
clc
-
clear
-
close all
-
-
% Calculate the distance between two points as the norm of the difference between the vector elements.
-
%
-
% Create two vectors representing the (x,y) coordinates for two points on the Euclidean plane.
-
-
a = [0 3];
-
b = [-2 1];
-
% Use norm to calculate the distance between the points.
-
-
d = norm(b-a)
d =
2.8284
几何上,两点之间的距离:
2-Norm of Matrix
-
clc
-
clear
-
close all
-
-
% Calculate the 2-norm of a matrix, which is the largest singular value.
-
-
X = [2 0 1;-1 1 0;-3 3 0];
-
n = norm(X)
-
% n = 4.7234
Frobenius Norm of Sparse Matrix
-
clc
-
clear
-
close all
-
-
% 使用'fro'计算稀疏矩阵的Frobenius范数,该范数计算列向量的2范数S(:)。
-
-
S = sparse(1:25,1:25,1);
-
n = norm(S,'fro')
-
% n = 5
文章来源: reborn.blog.csdn.net,作者:李锐博恩,版权归原作者所有,如需转载,请联系作者。
原文链接:reborn.blog.csdn.net/article/details/83119363
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)