minkowskidistance

It computes Lp Norm between two vectors or matrices of same length. If one of the inputs has one row and the other has 'm' rows, then distance is computed between one row and every other row. If p = 1, it becomes Manhattan distance. If p = 2, it becomes Euclidean distance. If p = n, then it becomes Ln Norm. It is a generalized formula for computing distances based on p value.

Attention: Available only with Activate commercial edition.

Syntax

Distance = minkowskidistance(X,Y,p)

Inputs

X
First input vector or matrix.
Type: double
Dimension: vector | matrix
Y
Second input vector or matrix.
Type: double
Dimension: vector | matrix
p
Represents the Lp norm (default: 2).
Type: integer
Dimension: scalar

Outputs

Distance
The distance between two inputs.
Type: double
Dimension: vector | matrix

Example

Example of minkowskidistance

x = [1, 2, 3];
y = [4, 5, 6];
%%When p = 1, it becomes L1 Norm or Manhattan Distance
printf('%f %f \n', minkowskidistance(x, y, 1), manhattanDistance(x, y));
9.000000 9.000000