您的位置:首页 > 编程语言 > MATLAB

Matlab norm 用法小记

2011-10-19 14:34 423 查看
 
norm(A,p)

当A是向量时

norm(A,p)  Returnssum(abs(A).^p)^(1/p),forany1<=p<=∞.

norm(A)   Returnsnorm(A,2)

norm(A,inf)  Returnsmax(abs(A)).

norm(A,-inf)  Returnsmin(abs(A)).

当A是矩阵时

n=norm(A)returnsthelargestsingularvalueofA,max(svd(A))

n=norm(A,1)The1-norm,orlargestcolumnsumofA,max(sum(abs(A)).

n=norm(A,2)Thelargestsingularvalue(sameasnorm(A)).

n=norm(A,inf)Theinfinitynorm,orlargestrowsumofA,max(sum(abs(A')))

n=norm(A,'fro')TheFrobenius-normofmatrixA,sqrt(sum(diag(A'*A))).

norm

Vectorandmatrixnorms

Syntax

n[code]
=
norm(A)
n
=
norm(A,p)
[/code]

Description

Thenormofamatrixisascalarthatgivessomemeasureofthemagnitudeoftheelementsofthematrix.The
norm
functioncalculatesseveraldifferenttypesofmatrixnorms:

n=norm(A)
returnsthelargestsingularvalueof
A
,
max(svd(A))
.

n=norm(A,p)
returnsadifferentkindofnorm,dependingonthevalueof
p.


If
p
is...
Then
norm
returns...
1
The1-norm,orlargestcolumnsumof
A
,
max(sum(abs(A))
.
2
Thelargestsingularvalue(sameas
norm(A)
).
inf
Theinfinitynorm,orlargestrowsumof
A
,
max(sum(abs(A')))
.
'fro'
TheFrobenius-normofmatrix
A
,
sqrt(sum(diag(A'
*
A)))
.
 
When
A
isavector:

norm(A,p)
Returns
sum(abs(A).^p)^(1/p)
,forany1
<=
p

<=


.
norm(A)
Returns
norm(A,2)
.
norm(A,inf)Returns
max(abs(A))
.
norm(A,-inf)Returns
min(abs(A))
.
 
Remarks

Notethat
norm(x)
istheEuclideanlengthofavector
x
.Ontheotherhand,MATLABuses"length"todenotethenumberofelements
n
inavector.Thisexampleuses
norm(x)/sqrt(n)
toobtainthe
root-mean-square(RMS)valueofan
n
-elementvector
x
.

x=[0123]
x=
0123

sqrt(0+1+4+9)%Euclideanlength
ans=
3.7417

norm(x)
ans=
3.7417

n=length(x)%Numberofelements
n=
4

rms=3.7417/2%rms=norm(x)/sqrt(n)
rms=
1.8708
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息