NORM Norm Calculation
Section: Array Generation and Manipulations
Usage
Calculates the norm of a matrix. There are two ways to use thenorm
function. The general syntax is
y = norm(A,p)
where A
is the matrix to analyze, and p
is the
type norm to compute. The following choices of p
are supported
-
p = 1
returns the 1-norm, or the max column sum of A -
p = 2
returns the 2-norm (largest singular value of A) -
p = inf
returns the infinity norm, or the max row sum of A -
p = 'fro'
returns the Frobenius-norm (vector Euclidean norm, or RMS value)
-
1 <= p < inf
returnssum(abs(A).^p)^(1/p)
-
p
unspecified returnsnorm(A,2)
-
p = inf
returns max(abs(A)) -
p = -inf
returns min(abs(A))
Examples
Here are the various norms calculated for a sample matrix--> A = float(rand(3,4)) A = 0.0063 0.2224 0.7574 0.9848 0.7319 0.1965 0.7191 0.7010 0.8319 0.6392 0.8905 0.9280 --> norm(A,1) ans = 2.6138 --> norm(A,2) ans = 2.3403 --> norm(A,inf) ans = 3.2896 --> norm(A,'fro') ans = 2.4353
Next, we calculate some vector norms.
--> A = float(rand(4,1)) A = 0.5011 0.3269 0.8192 0.7321 --> norm(A,1) ans = 2.3792 --> norm(A,2) ans = 1.2510 --> norm(A,7) ans = 0.8671 --> norm(A,inf) ans = 0.8192 --> norm(A,-inf) ans = 0.3269