Main Content


Dot product weight function


Z = dotprod(W,P,FP)
dim = dotprod('size',S,R,FP)
dw = dotprod('dw',W,P,Z,FP)
info = dotprod('code')


Weight functions apply weights to an input to get weighted inputs.

Z = dotprod(W,P,FP) takes these inputs,


S-by-R weight matrix


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


Struct of function parameters (optional, ignored)

and returns the S-by-Q dot product of W and P.

dim = dotprod('size',S,R,FP) takes the layer dimension S, input dimension R, and function parameters, and returns the weight size [S-by-R].

dw = dotprod('dw',W,P,Z,FP) returns the derivative of Z with respect to W.

info = dotprod('code') returns information about this function. The following codes are defined:


Name of derivative function


Input: reduced derivative = 2, full derivative = 1, linear derivative = 0


Weight: reduced derivative = 2, full derivative = 1, linear derivative = 0


Full name


Returns names of function parameters


Returns default function parameters


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 = dotprod(W,P)

Network Use

You can create a standard network that uses dotprod by calling feedforwardnet.

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

In either case, call sim to simulate the network with dotprod.

Version History

Introduced before R2006a