Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mandist

Manhattan distance weight function

Syntax

Z = mandist(W,P)
D = mandist(pos)

Description

mandist is the Manhattan distance weight function. Weight functions apply weights to an input to get weighted inputs.

Z = mandist(W,P) takes these inputs,

W

S-by-R weight matrix

P

R-by-Q matrix of Q input (column) vectors

and returns the S-by-Q matrix of vector distances.

mandist is also a layer distance function, which can be used to find the distances between neurons in a layer.

D = mandist(pos) takes one argument,

pos

S row matrix of neuron positions

and returns the S-by-S matrix of distances.

Examples

Here you define a random weight matrix W and input vector P and calculate the corresponding weighted input Z.

W = rand(4,3);
P = rand(3,1);
Z = mandist(W,P)

Here you define a random matrix of positions for 10 neurons arranged in three-dimensional space and then find their distances.

pos = rand(3,10);
D = mandist(pos)

Network Use

To change a network so an input weight uses mandist, set net.inputWeights{i,j}.weightFcn to 'mandist'. For a layer weight, set net.layerWeights{i,j}.weightFcn to 'mandist'.

To change a network so a layer's topology uses mandist, set net.layers{i}.distanceFcn to 'mandist'.

In either case, call sim to simulate the network with dist. See newpnn or newgrnn for simulation examples.

More About

collapse all

Algorithms

The Manhattan distance D between two vectors X and Y is

D = sum(abs(x-y))

See Also

| |

Introduced before R2006a

Was this topic helpful?