Euclidean distance weight function
information about this function. For more information, see the code
info = dist(
This example shows how to calculate the corresponding weighted input
Z, given a random weight matrix
W and input vector
W = rand(4,3); P = rand(3,1); Z = dist(W,P)
Here you define a random matrix of positions for 10 neurons arranged in three-dimensional space and find their distances.
pos = rand(3,10); D = dist(pos)
W— Weight matrix
Weight matrix, specified as an
P— Input matrix
Input matrix, specified as an
Q matrix of
Q input (column) vectors.
S— Layer dimension
Layer dimension, specified as a scalar.
R— Input dimension
Input dimension, specified as a scalar.
pos— Neuron positions
Matrix of neuron positions, specified as an
code— Information option
Information you want to retrieve from the function, specified as one of the following:
'name' returns the name of this function.
'deriv' returns the name of the derivative function
'fullderiv' returns 1 for full derivative and 0 for linear
'pfullderiv' returns 2 for reduced derivative, 1 for full
derivative, and 0 for linear derivative.
'fpnames' returns the names of the function parameters.
'fpdefaults' returns the default function parameters.
Z— Vector distances
Vector distances, returned as an
dim— Weight size
Weight size, returned as a row vector.
dw— Derivative of w
Z with respect to
W, returned as a
Distances, returned as an
You can create a standard network that uses
dist by calling
To change a network so an input weight uses
'dist'. For a layer
To change a network so that a layer’s topology uses
In either case, call
sim to simulate the network with
The Euclidean distance
d between two vectors
d = sum((x-y).^2).^0.5