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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
" {. g5 r9 F5 ?& g; P0 C
norm
2 H" m' h: X+ a# s# dVector and matrix norms$ ^$ ?" p  C& V2 K5 M% j

8 ~3 |! J4 R" z, SSyntax1 e1 w' ^$ D/ {3 U: I( j  u

1 ?9 F* b  p. |# ^! s* hn = norm(v); @- o1 }' F9 m. D) |  q3 B

/ C0 h4 q4 G$ q  dn = norm(v,p)& n& n0 h8 z5 J1 `# ]5 K; l6 ]$ h
/ z7 T) u0 J' y; L5 V* x
n = norm(X)
) `& T$ c, h  V+ J3 A! e; a/ ?% D6 ]; n1 V: b1 a4 I: c
n = norm(X,p)
& X4 `5 H% ~' _, y& X
' K6 F1 B, T: d' Bn = norm(X,'fro')
* N/ F8 g$ s7 f+ A8 a( H% D6 T6 q4 K) R
! @7 Y  N( y: P- f# D9 z( bDescription
+ U0 e  }/ e9 e2 F! Z& e  V% l8 K8 l
n = norm(v)返回向量v的欧几里德范数。该范数也称为2范数,向量幅度或欧几里德长度。
' O6 ^, I4 o8 R$ A4 y" e
8 i# v5 S& p6 ]n = norm(v,p)返回广义向量p范数。
+ D" i, J* a# \5 F
0 I% U' Z2 t6 A- b& Dn = norm(X)返回矩阵X的2范数或最大奇异值,其近似为max(svd(X))。
4 I1 u: S$ H2 R6 ~9 z0 d8 a# H
7 ~! M+ |8 P4 R" H7 n! R- on = norm(X,p)返回矩阵X的p范数,其中p为1,2或Inf:
) U% y( u. m" @7 A# b( y+ b# L& s
( T$ B8 y# j, x7 B3 M: h& f
  • 如果p = 1,则n是矩阵的最大绝对列和。
  • 如果p = 2,则n近似为max(svd(X))。 这相当于norm(X)。
  • 如果p = Inf,那么n是矩阵的最大绝对行和。$ P2 I& }1 \+ F8 @8 }" K% u  j; ~& j
; O. [, t* B' r% _4 \+ q' _! w
n = norm(X,'fro')返回矩阵X的Frobenius范数。7 `7 L6 e& d' w3 B9 `* B

( A$ ]" K- Q+ a有关范数的基础知识,见上篇文章:MATLAB必备的范数的基础知识
9 z- I$ N: Z1 {1 g5 D& M. }* K3 z) I4 k% a
下面举例说明:" _2 q' q! C, H9 w. i" ^
0 s$ E: B" s3 n2 h! Q
Vector Magnitude(向量幅度)
7 [2 T5 k. z1 ?0 [8 f, G& e' X& G# E0 N/ Z& I  ~; I3 B! Q# `
  • %Create a vector and calculate the magnitude.
  • v = [1 -2 3];
  • n = norm(v)
  • % n = 3.7417
    ) ^& b' O, i8 h6 p
! J6 F8 I/ J* O
; g1 m& P; t1 |% ~
1-Norm of Vector
# B% f- a& C% w2 `! s( g8 c. T
$ N6 o4 O. h- m" ^9 d
  • 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  J3 v/ H: V. m  N
  
7 `* B$ }1 e1 _" n* H) K+ wEuclidean Distance Between Two Points  ]9 D) e  z% K9 ^

5 B/ x# ~( X# K: G2 V$ |6 M2 k" F
  • 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)
    4 X: e0 F5 Q* P
   
2 y5 i3 O- ]% O* M. jd =
1 S, ?1 i( c/ {3 v7 S& t! z. u3 ?" J9 U; X3 B) z5 O
    2.8284
) q5 @2 j5 y0 B. ]6 p% h9 Q
! D" [6 Z- m# @7 f% B: u1 J$ Z几何上,两点之间的距离:3 y- Z/ K  ~; T9 P

, m( Y6 a1 w" }5 V* l% Y) Y : E% d3 X" G( k, o9 r& ]' z

4 s5 {$ a- [- \" A, [. H% R8 _! y
* L9 a6 M/ ]* C2 @3 L; n2-Norm of Matrix2 o6 F; c# T! i2 X: x  A" w% _

/ ^; A; V' y3 v2 T  r. N
  • 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, W' c  [. R/ Y
  $ `. n* X* l; ~& }( q) e
Frobenius Norm of Sparse Matrix% h* c+ ?$ g- W' z
5 f  f' i3 _, ^' T- ]: o$ @
% W# ]: B7 d5 j" D
  • clc
  • clear
  • close all
  • % 使用'fro'计算稀疏矩阵的Frobenius范数,该范数计算列向量的2范数S(:)。
  • S = sparse(1:25,1:25,1);
  • n = norm(S,'fro')
  • % n = 5! h# \$ a8 w0 v: m2 s. b7 u
   1 {( C  }" X+ z( j. j# i6 F
9 }5 ~7 K6 l; Y" h; @

) `) ]4 O2 U& p( E0 u
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-11-23 19:41 , Processed in 0.140625 second(s), 26 queries , Gzip On.

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

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

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