distLpNorm
Lp norm of a vector
Contents
Syntax
- out=distLpNorm(vec, p)
Description
out=distLpNorm(x, p) returns the Lp norm of a given vector x.
- x: a column vector or a matrix
- p: a parameter between 0 and infinity
If x is a matrix, then Lp norm is applied to each column vector.
Example
vec=[3; 4]; fprintf('distLpNorm([3; 4], 1) = %f\n', distLpNorm(vec, 1)); fprintf('distLpNorm([3; 4], 2) = %f\n', distLpNorm(vec, 2)); fprintf('distLpNorm([3; 4], inf) = %f\n', distLpNorm(vec, inf));
distLpNorm([3; 4], 1) = 7.000000 distLpNorm([3; 4], 2) = 5.000000 distLpNorm([3; 4], inf) = 4.000000