norm
Compute matrix and vector norms.
Syntax
R = norm(x)
R = norm(x,p)
R = norm(x,type)
R = norm(...,opt)
Inputs
- x
- The vector or matrix whose norm is computed.
- p
- A parameter that specifies the vector p-norm (default: 2).
- type
- Specifies an infinity norm or the Frobenius norm.
- opt
- 'rows' or 'cols'.
Outputs
- R
- The norm output.
Examples
R = norm([3,6,4,2,5,8])
R = 12.4096736
R = norm([3,6,4;2,5,8;6,1,7],'fro')
R = 15.4919334
Comments
For a vector input with p=2, the norm is the geometric vector length.
For a vector input with p=0, the Hamming norm is the number of non-zero elements.