norm
Vector or matrix norm.
Syntax
Section titled “Syntax”n = norm(A)n = norm(A, p)n = norm(A, 'fro')Description
Section titled “Description”Returns the norm of A. The interpretation depends on A’s shape and the p argument:
- For vectors:
p = 2(default) is the Euclidean norm,p = 1the sum of absolute values,p = Infthe max absolute value, any positive scalarpthe p-norm. - For matrices:
p = 2(default) is the largest singular value,p = 1the max column sum,p = Infthe max row sum,'fro'the Frobenius norm (sqrt of sum of squared entries).
Examples
Section titled “Examples”norm([3 4]) % 5 (Euclidean)norm([3 4], 1) % 7 (sum of |x|)norm(magic(3)) % 15 (largest singular value)norm(magic(3), 'fro') % ~16.882