Section: Array Generation and Manipulations
norm 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 returns sum(abs(A).^p)^(1/p)
p unspecified returns norm(A,2)
p = inf returns max(abs(A))
p = -inf returns min(abs(A))
--> A = float(rand(3,4))
A =
0.4266 0.0755 0.8713 0.4876
0.8799 0.1549 0.3731 0.4750
0.0417 0.1658 0.5522 0.5067
--> norm(A,1)
ans =
1.7967
--> norm(A,2)
ans =
1.5921
--> norm(A,inf)
ans =
1.8830
--> norm(A,'fro')
ans =
1.7143
Next, we calculate some vector norms.
--> A = float(rand(4,1))
A =
0.6840
0.2036
0.9099
0.6971
--> norm(A,1)
ans =
2.4946
--> norm(A,2)
ans =
1.3503
--> norm(A,7)
ans =
0.9437
--> norm(A,inf)
ans =
0.9099
--> norm(A,-inf)
ans =
0.2036