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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
- G( }' X% K; n
norm
* o1 q1 y* ~5 b% \2 h7 u( XVector and matrix norms2 `+ ?( W; f# g, {
1 s( J/ Q  X! c) M4 f
Syntax* a% d& i; @' b9 a- @% d: q
5 Y: p0 Z* L( q5 Y; n7 d5 @; B
n = norm(v)( Y: }* c% p; q& J- ?) W

/ }" y" ^, Q8 m5 e% J. }8 en = norm(v,p)
" H; X+ i* }# b5 u5 q
6 {- r- N# b+ X6 \n = norm(X)# B- z; q+ h( [
3 d4 n* \9 T8 ~0 f
n = norm(X,p)' F; z0 C6 E+ \1 d! i( x

( d; Q9 z4 v# in = norm(X,'fro')
- Z7 A1 m. J5 ~( h! ]
6 |0 S* F9 T# _+ ?& H$ u! nDescription
; p+ O% k4 p; w. z
: ^/ C/ O: |8 P3 \n = norm(v)返回向量v的欧几里德范数。该范数也称为2范数,向量幅度或欧几里德长度。
+ a2 l( K. L% j; ^3 K& E7 G1 {8 z- a
n = norm(v,p)返回广义向量p范数。
/ y' X, J* N+ Z0 t3 x) S/ L4 a# T/ u( p) s3 }7 |7 J
n = norm(X)返回矩阵X的2范数或最大奇异值,其近似为max(svd(X))。
- m- @7 P# R' s( J4 O) |9 T8 F1 b: f" V  j
n = norm(X,p)返回矩阵X的p范数,其中p为1,2或Inf:& r1 j( X  x$ ?4 H- F

0 y% u) M1 |' [+ L. v2 {
  • 如果p = 1,则n是矩阵的最大绝对列和。
  • 如果p = 2,则n近似为max(svd(X))。 这相当于norm(X)。
  • 如果p = Inf,那么n是矩阵的最大绝对行和。1 k. E% K% o. _& [$ S

; l$ K' v! H( x! }# I6 U5 o- |$ ~n = norm(X,'fro')返回矩阵X的Frobenius范数。* O# w3 R2 ]% r1 K
' n* t9 E. L0 [! I- @1 O  A. h
有关范数的基础知识,见上篇文章:MATLAB必备的范数的基础知识0 E* a) H, _5 U5 u& @

& a5 k" ]' v$ @2 P下面举例说明:
) O2 d$ I3 x: u% F7 b' j  g) s. [4 k6 o9 u" l
Vector Magnitude(向量幅度)4 R  R8 u$ e- H+ x  Q$ M
" l& P) d) O8 b- ^; D- D! ?( `( o
  • %Create a vector and calculate the magnitude.
  • v = [1 -2 3];
  • n = norm(v)
  • % n = 3.7417
    ; e: W+ Z+ W! J7 j$ t0 a6 P% R& v2 }

; G7 c( `. W1 m# A7 I) N
6 r  h) B# c1 K, B) K4 |1-Norm of Vector7 e/ v. p1 K7 y3 x

8 e8 l; j2 `! L4 B, y. n; t" L
  • 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
    " h' v) ~# T4 _0 |+ ~* Q" x2 Y
  
0 K0 |4 \# H4 L# b: KEuclidean Distance Between Two Points2 u5 Q7 @* W, Z8 |, f  g' D# ?3 [
$ v) R. f4 S7 X  I1 v. A- T  q; k
  • 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)
    : K/ ^1 D- f1 I
   
& b) o. [" X% v' N2 v, d" A. |d =
% V- O3 T( q4 t
! h: @( ^8 f) J1 t7 `+ A    2.8284
. s1 n$ f+ Q( ^; \. w3 j  E2 ^6 h2 a  P) D) B+ a( e
几何上,两点之间的距离:
7 j+ A* }! Q" |( d
9 a; d7 @4 L; K6 b% w- J, f
! k+ b3 d" n3 B" Y, Q- [6 S& F) g5 w- i3 \5 y* S6 Y
! ], }" R, n5 U% p% Z5 u, N
2-Norm of Matrix" u# O0 Q: Y' [- q9 _

9 q# M" J% E. h& w% Z6 z
  • 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.72347 N! x* a3 V) n8 |$ e
  
$ U. x  |! N2 K! f! OFrobenius Norm of Sparse Matrix
, h$ f5 T2 K! j7 D' Z6 b
. d* `- @& u3 Z2 l7 ^% g* U! M* J3 Y0 h; O7 N8 ~, I& l
  • clc
  • clear
  • close all
  • % 使用'fro'计算稀疏矩阵的Frobenius范数,该范数计算列向量的2范数S(:)。
  • S = sparse(1:25,1:25,1);
  • n = norm(S,'fro')
  • % n = 5$ F  M) r: a: y
   
, l' R" F3 s' r3 u3 N. _' g
5 ]1 E- g* N+ {2 D6 Y
7 C+ p3 g: H. q+ y. l( i4 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-10-5 17:29 , Processed in 0.140625 second(s), 26 queries , Gzip On.

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

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

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