norm()

格式:n=norm(A,p) 功能:norm函式可計算幾種不同類型的矩陣範數,根據p的不同可得到不同的範數

格式

n = norm(A);

n = norm(A,p);

功能描述

The norm of a matrix is a scalar that gives some measure of the magnitude of the elements of the matrix. The norm function calculates several different types of matrix norms:

n = norm(A) returns the largest singular value of A, max(svd(A)).

n = norm(A,p) returns a different kind of norm, depending on the value of p.

if p is...The norm return ...
1The 1-norm, or largest column sum of A, max(sum(abs(A))
2The largest singular value (same as norm(A))
inf The infinity norm, or largest row sum of A, max(sum(abs(A')))
' fro 'The Frobenius-norm of matrix A, sqrt(sum(diag(A'*A)))

When A is a vector:

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

norm(A)Returns norm(A,2).

norm(A,inf)Returns max(abs(A)).

norm(A,-inf)Returns min(abs(A)).

1、如果A為矩陣

n=norm(A)
返回A的最大奇異值,即max(svd(A))
n=norm(A,p)
根據p的不同,返回不同的值

p值返回值
1返回A中最大一列和,即max(sum(abs(A)))
2返回A的最大奇異值,和n=norm(A)用法一樣
inf返回A中最大一行和,即max(sum(abs(A’)))
‘fro’A和A‘的積的對角線和的平方根,即sqrt(sum(diag(A'*A)))

2、如果A為向量

norm(A,p)
返回向量A的p範數。即返回 sum(abs(A).^p)^(1/p),對任意 1<p<+∞.
norm(A)
返回向量A的2範數,即等價於norm(A,2)。
norm(A,inf)
返回max(abs(A))
norm(A,-inf)
返回min(abs(A))

實例

x = [0 1 2 3]
x =
0 1 2 3

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

norm(x)
ans =
3.7417

n = length(x) % Number of elements
n =
4

rms = 3.7417/2 % rms = norm(x)/sqrt(n)
rms =
1.8708

相關詞條

熱門詞條

聯絡我們