找回密码
 注册
关于网站域名变更的通知
查看: 469|回复: 1
打印 上一主题 下一主题

认识一下MATLAB 的norm ( Vector and matrix norms )(向量范数以及矩阵范数)函数

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-12-23 13:35 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x

, @# d& S% i* h, T' v4 mnorm7 Z9 P3 a* @/ w% ]6 u% h
Vector and matrix norms
* O! Y1 ?6 v( k+ J1 Q# F! z0 g) Q5 Q5 B! s8 `
Syntax/ P  k! b% X2 G+ ^- {2 b2 b, m

5 X$ I3 D8 [( Y& V% un = norm(v)
, U  B" s! h% T& F' [, @% O! d6 C3 {6 ^$ p
n = norm(v,p)
. G( ?5 t6 E: Y
/ ~  v; q# Q: F% _0 R- [3 l) Jn = norm(X)1 E9 W1 f9 R) m/ g: e/ p) E, Q0 T. o

1 N- N  A4 k! f5 e/ s& \n = norm(X,p)
# l% O7 P# b; [( d; j4 Y3 I5 Q4 ]5 d+ c7 E1 R; }& u- C. W0 S
n = norm(X,'fro')" d$ |- `; j' D
. E8 c1 D, ?( B8 F  y5 k
Description
1 E8 S8 @/ V* c9 _, U
* {/ o3 E( z/ ~" v' j# bn = norm(v)返回向量v的欧几里德范数。该范数也称为2范数,向量幅度或欧几里德长度。
0 n/ w! ~: B/ m  K, a! p, j" g
6 A& H3 ^8 w8 T; A: w0 k: S) Nn = norm(v,p)返回广义向量p范数。
' W4 n9 f- q; [+ X& n
3 [2 I  @) N; V& X1 hn = norm(X)返回矩阵X的2范数或最大奇异值,其近似为max(svd(X))。3 n3 n- r& S. u5 Q- x$ x1 a( r
7 N+ ^; I# o0 x; o
n = norm(X,p)返回矩阵X的p范数,其中p为1,2或Inf:
+ ?8 c. x$ j; w# b9 }' }+ t
! B( b  P& h3 c% O
  • 如果p = 1,则n是矩阵的最大绝对列和。
  • 如果p = 2,则n近似为max(svd(X))。 这相当于norm(X)。
  • 如果p = Inf,那么n是矩阵的最大绝对行和。8 q/ S* D' e; {+ y2 Z+ \) D) Q8 Y

0 ^6 W) j) X/ n. S& pn = norm(X,'fro')返回矩阵X的Frobenius范数。+ W1 w' T$ V7 V3 f* l$ p
1 }4 G" [: x" d7 L9 _; _) C" ^
有关范数的基础知识,见上篇文章:MATLAB必备的范数的基础知识$ u: d/ R. P% E* I6 H, D
! W& C, Q& j- k; u$ W" p
下面举例说明:
' W* b0 W2 j9 ]# y* ], R" S' g2 u0 z% e* c' _/ k0 ?
Vector Magnitude(向量幅度)
- n! Q1 s! \  H
7 ~- x3 a' X! h: q4 K) r7 @* ]
  • %Create a vector and calculate the magnitude.
  • v = [1 -2 3];
  • n = norm(v)
  • % n = 3.7417  V/ y' i/ T" i/ f
- ?8 f4 n% T6 I- {  A4 z; X% f
8 M+ v. v6 f: V! f1 u
1-Norm of Vector
# e5 T4 B8 U  v2 F7 ~! v
1 U" c1 j7 D: p7 H" [$ Y! n
  • 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
    & }( ?$ t$ f: h7 q8 K$ Q7 T' O
  
. t3 \. y9 w% aEuclidean Distance Between Two Points
, z$ t! D: W- v" O
! q; K8 J4 A% I* G3 w6 `: x/ u' \
  • 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)9 u/ h, Z2 z- X& Z8 d/ B! Q3 |3 v
   1 A: A9 Z0 y$ c4 i- V, Y, Z
d =6 B6 G7 ^! l* V3 f& W' u& `" p" T6 y
% x0 f9 _, f4 _, L, R
    2.8284
6 g; S( K! I9 o5 |+ p+ d+ U( v8 o, e& ?5 C9 o1 s& E' N
几何上,两点之间的距离:
/ H3 ~9 o0 A3 d, q+ u
" o7 O; S5 p1 I3 @! @
3 K/ d5 i8 b1 T; ?* B2 v/ Q. D! H. i5 Y  k

7 @( @7 R2 H8 j: S" H9 {( I! D% I2-Norm of Matrix! ^( q5 B0 Y+ ^+ h3 g# H
2 j+ |5 {+ w) a- {6 f$ X1 s
  • 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
    * H5 X/ f5 y6 p
  
" F+ e; K1 R, y+ v7 w, }Frobenius Norm of Sparse Matrix( U  l' u4 l; V, e! ^9 O

5 V: @+ ^9 A5 F! k. V- u  t4 [, R
: N* \5 }" s% l" r( v# J8 _
  • clc
  • clear
  • close all
  • % 使用'fro'计算稀疏矩阵的Frobenius范数,该范数计算列向量的2范数S(:)。
  • S = sparse(1:25,1:25,1);
  • n = norm(S,'fro')
  • % n = 5
    ; Q. t3 r, [& W+ N7 `' L5 S
   
  ^( K. J9 o  T/ d: I4 [. y% m/ o7 K( H$ j* Y: w7 e) q! H
( C5 b0 h. Q7 ~& N, a3 j/ x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-11-23 20:57 , Processed in 0.171875 second(s), 26 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表