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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
! m+ e' x% t5 t8 J( e% q8 E6 p4 F5 N
norm
2 B, q0 j; J2 m9 {2 L" KVector and matrix norms* {* u6 R8 y/ ^6 o, T+ d+ G
' B: T6 J* M% K! V  L, h2 E
Syntax
2 u$ e% Z6 [9 k2 p- |7 _% S8 X
% C+ s8 i  @) J% Jn = norm(v)* V# R. O% I  ]( W! l

. a* I. Z2 d: Q1 X$ p6 T$ Gn = norm(v,p)
" a0 F3 k9 I! M1 R2 a
) B& l& @4 L3 Q+ Nn = norm(X), a3 w" o! e( d

- `1 V6 a* d/ |  F8 |n = norm(X,p)! z4 v: S- ]  i2 @6 N' R

; u7 |2 |9 N' a9 o1 u- w7 j, k5 `4 `n = norm(X,'fro')
1 y4 z+ d% y1 U9 ]% M9 i3 @" m* x5 g, c. A+ C3 g
Description
& U9 u" g5 B* V9 F# Q+ v7 G; H- V! w
n = norm(v)返回向量v的欧几里德范数。该范数也称为2范数,向量幅度或欧几里德长度。
9 _1 c2 `9 o9 C% I# b$ n+ p! i* S8 N, H( {7 j
n = norm(v,p)返回广义向量p范数。5 u! H  s9 @7 T
. f! ~* a0 }8 k  w+ A1 {& B
n = norm(X)返回矩阵X的2范数或最大奇异值,其近似为max(svd(X))。8 k2 p7 r$ r& V
& ?* A: Q: Q$ p4 W/ I. i/ _+ G
n = norm(X,p)返回矩阵X的p范数,其中p为1,2或Inf:/ y2 h& d$ U3 _3 C& W. c) ?+ s
% x1 C+ b+ r8 _! |* g
  • 如果p = 1,则n是矩阵的最大绝对列和。
  • 如果p = 2,则n近似为max(svd(X))。 这相当于norm(X)。
  • 如果p = Inf,那么n是矩阵的最大绝对行和。
    ' K7 A5 _8 U' q$ P& c, a
! U! v( P" y8 C
n = norm(X,'fro')返回矩阵X的Frobenius范数。; ~! X7 _) b1 G5 h6 K3 ?4 {1 I

" j( q& N, F8 c有关范数的基础知识,见上篇文章:MATLAB必备的范数的基础知识/ r- P, t7 C4 S+ i4 t: @& y5 M
/ l7 d# g' Z- F0 ~2 ?, C0 w
下面举例说明:2 X$ k; o! e* y% O& `# w
# E( k9 h- f7 O8 ^& [! I! Z+ s& J
Vector Magnitude(向量幅度)
& G/ F3 P: _% E) w3 `+ r7 v/ g, B! l' `* ^; S9 C. Q; j; s
  • %Create a vector and calculate the magnitude.
  • v = [1 -2 3];
  • n = norm(v)
  • % n = 3.7417
    " c8 j3 R/ }4 o! e# m; D% p( ^0 Y
  F# y! w2 [: e1 q+ L6 B+ {5 s

7 m4 {* ]( ~6 [, m9 ~1-Norm of Vector9 q" I- ^& q- y# x

+ a  Z9 G" j) }
  • 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
    / ?' `0 z/ \$ \5 z
  
% }9 y1 H7 ^; qEuclidean Distance Between Two Points
9 @0 X: ?9 {, G" r& l" O# X# R. M6 Z( x$ m/ Q1 Y; d# x
  • 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)2 b2 n8 I1 M0 ~, {& `4 b
   " d; n8 s" o3 H) |* x# c
d =
  y. o( f, T% X$ ?, @" C0 t# ~" ?* ~* q- m5 _
    2.8284! z# ]% d- P) C: I  z5 }) g

2 t8 }$ ]% {1 Z, f几何上,两点之间的距离:
- e3 }& ?! j9 }" S1 W3 _5 t$ i! d( x: j) A

- ?( [' q- D3 J) }# k$ v9 m, k
( a* j$ v5 _6 O# W+ c. N  a; n
8 e3 \# K+ a, a  p8 @2 d$ F& f2-Norm of Matrix2 k1 F! y+ |5 i  N4 \+ G4 x* w
6 ~/ h& l( y: E) j  o
  • 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% G' N( u: y: R: J" B
  
6 d' s3 a7 A4 L: U, e1 n2 F  VFrobenius Norm of Sparse Matrix& b4 i# w4 f- E

# X; q% K$ ?2 e. o4 E
1 ^( z) n5 `3 Z+ {  B& C
  • clc
  • clear
  • close all
  • % 使用'fro'计算稀疏矩阵的Frobenius范数,该范数计算列向量的2范数S(:)。
  • S = sparse(1:25,1:25,1);
  • n = norm(S,'fro')
  • % n = 58 j  T6 t  u3 I; A
   
; I/ t2 V5 v- \5 T- {" j* \1 h
0 {3 {2 @' _5 I/ j; |$ \6 _5 \( O. m, q; N" y
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

EDA365公众号

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

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

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

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

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