Back to Linear Algebra

norm

Matrix or vector norm

Syntax

n = norm(A)
n = norm(A, p)
n = norm(A, 'fro')

Description

Computes the norm of a vector or matrix. For vectors, the default is the 2-norm (Euclidean). For matrices, the default is the Frobenius norm. An optional second argument specifies the norm order (1, 2, etc.) or type ('fro' for Frobenius, 'nuc' for nuclear).

Parameters

NameDescription
AInput vector or matrix
p(optional)Norm order or type: number (1, 2, Inf), or string ('fro', 'nuc')

Returns

Scalar norm value

Examples

Try It
>> norm([3 4])
5
Try It
>> norm([3 4], 1)
7
Try It
>> norm([1 2; 3 4], 'fro')

See Also