關閉→
當前位置:知科普>IT科技>(a) 用法以及實例 - matlab norm

(a) 用法以及實例 - matlab norm

知科普 人氣:9K
matlab norm函數可計算幾種不同類型的矩陣範數,根據p的不同可得到不同的範數,在這裏小編來介紹它的用法以及實例,希望會幫助到你。

matlab norm (a) 用法以及實例

方法

當A是向量的時候,法則如下:
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)).

matlab norm (a) 用法以及實例 第2張

我們以下面這個例子來説明:

B =
0 12
在MATLAB中分別輸入如下命令:
當P為正整數時,norm(B,p)=sum(abs(A).^p)^(1/p)
norm(B,2)=norm(B)=5^0.5=2.2361
norm(B,1)=3
norm(B,'inf')=max(abs(B))=2
norm(B,'fro')B的Frobenius範數;

>>norm(B)

ans=

2.2361

>>norm(B,1)

ans=

3


matlab norm (a) 用法以及實例 第3張

步驟比較長,接着來:

norm(B,'inf')=max(abs(B))=2
norm(B,'fro')B的Frobenius範數;
>>norm(B,'inf')
ans=
2
>>norm(B,'inf')
ans=
2.2361

matlab norm (a) 用法以及實例 第4張

當A是矩陣的時候:
n = norm(A) returns the largest singular value of A, max(svd(A))
n = norm(A,1) The 1-norm, or largest column sum of A, max(sum(abs(A)).
n = norm(A,2) The largest singular value (same as norm(A)).
n = norm(A,inf) The infinity norm, or largest row sum of A, max(sum(abs(A‘)))
n = norm(A,‘fro‘) The Frobenius-norm of matrix A, sqrt(sum(diag(A‘*A))).

matlab norm (a) 用法以及實例 第5張

以此為例;

A =
0 1 2
3 4 5
6 7 8
在MATLAB中分別輸入如下指令
norm(A)/norm(A,2),返回的是矩陣A的二範數,(二範數j就是矩陣A的2範數就是 A的轉置矩陣乘以A特徵根 最大值的開根號)
norm(A,1),返回矩陣的1泛數,是最大一列的和,從上面矩陣看,norm(A,1)=15

>>norm(A)

ans=

14.2267

>>norm(A,2)

ans=

14.2267

>>norm(A,1)

ans=

15


matlab norm (a) 用法以及實例 第6張

norm(A,'inf') 返回矩陣的無窮泛數,也就是最大一行的和,norm(A,'inf')=21
norm(A,'fro') 返回矩陣的Frobenius範數,

>>norm(A,'inf')
ans=

21

>>norm(A,'fro')

ans=

14.2829

matlab norm (a) 用法以及實例 第7張
TAG標籤:#norm #實例 #matlab #