function nnt_con

% NNT_CON Show the help for the functions in this toolbox.

% This file is automatically generated.  Matthew Simoneau, 09-04-98
% Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved
% $Revision: 1.11 $ $Date: 1998/10/16 23:19:29 $

helpwin('nnt_con/Contents');

function Contents
%MATLAB Tour Partial Function Help:  nnt_con
%
%Double click on any function for more information
%
%  Neural Network Toolbox.
%  Version 3.0.1  (R11) 01-Jul-1998
% 
%  Adapt functions.
%    adaptwb  - By-weight-and-bias network adaption function.
% 
%  Analysis functions.
%    errsurf  - Error surface of single input neuron.
%    maxlinlr - Maximum learning rate for a linear layer.
% 
%  Distance functions.
%    boxdist  - Box distance function.
%    dist     - Euclidiean distance weight function.
%    mandist  - Manhattan distance weight function.
%    linkdist - Link distance function.
% 
%  Layer initialization functions.
%    initnw   - Nguyen-Widrow layer initialization function.
%    initwb   - By-weight-and-bias layer initialization function.
% 
%  Learning functions.
%    learncon - Conscience bias learning function.
%    learngd  - Gradient descent weight/bias learning function.
%    learngdm - Gradient descent w/momentum weight/bias learning function.
%    learnh   - Hebb weight learning function.
%    learnhd  - Hebb with decay weight learning function.
%    learnis  - Instar weight learning function.
%    learnk   - Kohonen weight learning function.
%    learnlv1 - LVQ1 weight learning function.
%    learnlv2 - LVQ2 weight learning function.
%    learnos  - Outstar weight learning function.
%    learnp   - Perceptron weight/bias learning function.
%    learnpn  - Normalized perceptron weight/bias learning function.
%    learnsom - Self-organizing map weight learning function.
%    learnwh  - Widrow-Hoff weight/bias learning rule.
% 
%  Line search functions.
%    srchbac  - Backtracking search.
%    srchbre  - Brent's combination golden section/quadratic interpolation.
%    srchcha  - Charalambous' cubic interpolation.
%    srchgol  - Golden section search.
%    srchhyb  - Hybrid bisection/cubic search.
% 
%  New networks.
%    network  - Create a custom neural network.
%    newc     - Create a competitive layer.
%    newcf    - Create a cascade-forward backpropagation network.
%    newelm   - Create an Elman backpropagation network.
%    newff    - Create a feed-forward backpropagation network.
%    newfftd  - Create a feed-forward input-delay backprop network.
%    newgrnn  - Design a generalized regression neural network.
%    newhop   - Create a Hopfield recurrent network.
%    newlin   - Create a linear layer.
%    newlind  - Design a linear layer.
%    newlvq   - Create a learning vector quantization network.
%    newp     - Create a perceptron.
%    newpnn   - Design a probabilistic neural network.
%    newrb    - Design a radial basis network.
%    newrbe   - Design an exact radial basis network.
%    newsom   - Create a self-organizing map.
% 
%  Net input functions.
%    netprod  - Product net input function.
%    netsum   - Sum net input function.
% 
%  Net input derivative functions.
%    dnetprod - Product net input derivative function.
%    dnetsum  - Sum net input derivative function.
% 
%  Network initialization functions.
%    initlay  - Layer-by-layer network initialization function.
% 
%  Performance functions.
%    mae      - Mean absolute error performance function.
%    mse      - Mean squared error performance function.
%    msereg   - Mean squared error with regularization performance function.
%    sse      - Sum squared error performance function.
% 
%  Performance derivative functions.
%    dmae     - Mean absolute error performance derivatives function.
%    dmse     - Mean squared error performance derivatives function.
%    dmsereg  - Mean squared error w/reg performance derivative function.
%    dsse     - Sum squared error performance derivative function.
% 
%  Plotting functions.
%    hintonw  - Hinton graph of weight matrix.
%    hintonwb - Hinton graph of weight matrix and bias vector.
%    plotbr   - Plot network performance for Bayesian regularization training.
%    plotes   - Plot an error surface of a single input neuron.
%    plotpc   - Plot classification line on perceptron vector plot.
%    plotpv   - Plot perceptron input/target vectors.
%    plotep   - Plot a weight-bias position on an error surface.
%    plotperf - Plot network performance.
%    plotsom  - Plot self-organizing map.
%    plotv    - Plot vectors as lines from the origin.
%    plotvec  - Plot vectors with different colors.
% 
%  Pre and Post Processing.
%    prestd   - Normalize data for unity standard deviation and zero mean.
%    poststd  - Unnormalize data which has been normalized by PRESTD.
%    trastd   - Transform data with precalculated mean and standard deviation.
%    premnmx  - Normalize data for maximum of 1 and minimum of -1.
%    postmnmx - Unnormalize data which has been normalized by PREMNMX.
%    tramnmx  - Transform data with precalculated minimum and maximum.
%    prepca   - Principal component analysis on input data.
%    trapca   - Transform data with PCA matrix computed by PREPCA.
%    postreg  - Post-training regression analysis.
% 
%  Simulink support.
%    gensim   - Generate a SIMULINK block to simulate a neural network.
% 
%  Topology functions.
%    gridtop  - Grid layer topology function.
%    hextop   - Hexagonal layer topology function.
%    randtop  - Random layer topology function.
% 
%  Training functions.
%    trainbfg - BFGS quasi-Newton backpropagation.
%    trainbr  - Bayesian regularization.
%    traincgb - Powell-Beale conjugate gradient backpropagation.
%    traincgf - Fletcher-Powell conjugate gradient backpropagation.
%    traincgp - Polak-Ribiere conjugate gradient backpropagation.
%    traingd  - Gradient descent backpropagation.
%    traingdm - Gradient descent with momentum backpropagation.
%    traingda - Gradient descent with adaptive lr backpropagation.
%    traingdx - Gradient descent w/momentum & adaptive lr backpropagation.
%    trainlm  - Levenberg-Marquardt backpropagation.
%    trainoss - One step secant backpropagation.
%    trainrp  - Resilient backpropagation (Rprop).
%    trainscg - Scaled conjugate gradient backpropagation.
%    trainwb  - By-weight-and-bias network training function.
%    trainwb1 - By-weight-&-bias 1-vector-at-a-time training function.
% 
%  Transfer functions.
%    compet   - Competitive transfer function.
%    hardlim  - Hard limit transfer function.
%    hardlims - Symmetric hard limit transfer function.
%    logsig   - Log sigmoid transfer function.
%    poslin   - Positive linear transfer function.
%    purelin  - Linear transfer function.
%    radbas   - Radial basis transfer function.
%    satlin   - Saturating linear transfer function.
%    satlins  - Symmetric saturating linear transfer function.
%    softmax  - Soft max transfer function.
%    tansig   - Hyperbolic tangent sigmoid transfer function.
%    tribas   - Triangular basis transfer function.
% 
%  Transfer derivative functions.
%    dhardlim - Hard limit transfer derivative function.
%    dhardlms - Symmetric hard limit transfer derivative function.
%    dlogsig  - Log sigmoid transfer derivative function.
%    dposlin  - Positive linear transfer derivative function.
%    dpurelin - Hard limit transfer derivative function.
%    dradbas  - Radial basis transfer derivative function.
%    dsatlin  - Saturating linear transfer derivative function.
%    dsatlins - Symmetric saturating linear transfer derivative function.
%    dtansig  - Hyperbolic tangent sigmoid transfer derivative function.
%    dtribas  - Triangular basis transfer derivative function.
% 
%  Update networks from previous versions.
%    nnt2c    - Update NNT 2.0 competitive layer to NNT 3.0.
%    nnt2elm  - Update NNT 2.0 Elman backpropagation network to NNT 3.0.
%    nnt2ff   - Update NNT 2.0 feed-forward network to NNT 3.0.
%    nnt2hop  - Update NNT 2.0 Hopfield recurrent network to NNT 3.0.
%    nnt2lin  - Update NNT 2.0 linear layer to NNT 3.0.
%    nnt2lvq  - Update NNT 2.0 learning vector quantization network to NNT 3.0.
%    nnt2p    - Update NNT 2.0 perceptron to NNT 3.0.
%    nnt2rb   - Update NNT 2.0 radial basis network to NNT 3.0.
%    nnt2som  - Update NNT 2.0 self-organizing map to NNT 3.0.
% 
%  Using networks.
%    sim      - Simulate a neural network.
%    init     - Initialize a neural network.
%    adapt    - Allow a neural network to adapt.
%    train    - Train a neural network.
%    disp     - Display a neural network's properties.
%    display  - Display the name and properties of a neural network variable.
% 
%  Vectors.
%    cell2mat - Combine cell array of matrices into one matrix.
%    concur   - Create concurrent bias vectors.
%    con2seq  - Convert concurrent vectors to sequential vectors.
% 	combvec  - Create all combinations of vectors.
%    ind2vec  - Convert indices to vectors.
%    mat2cell - Break matrix up into cell array of matrices.
%    minmax   - Ranges of matrix rows.
%    nncopy   - Copy matrix or cell array.
%    normc    - Normalize columns of a matrix.
%    normr    - Normalize rows of a matrix.
%    pnormc   - Pseudo-normalize columns of a matrix.
%    quant    - Discretize values as multiples of a quantity.
%    seq2con  - Convert sequential vectors to concurrent vectors.
%    sumsqr   - Sum squared elements of matrix.
%    vec2ind  - Convert vectors to indices.
% 
%  Weight functions.
%    dist     - Euclidean distance weight function.
%    dotprod  - Dot product weight function.
%    mandist  - Manhattan distance weight function.
%    negdist  - Dot product weight function.
%    normprod - Normalized dot product weight function.
% 
%  Weight and bias initialization functions.
%    initcon  - Conscience bias initialization function.
%    initzero - Zero weight/bias initialization function.
%    midpoint - Midpoint weight initialization function.
%    randnc   - Normalized column weight initialization function.
%    randnr   - Normalized row weight initialization function.
%    rands    - Symmetric random weight/bias initialization function.
% 
%  Weight derivative functions.
%    ddotprod - Dot product weight derivative function.
% 
%  For functions listed by network type:
% 
%    assoclr  - Associative learning rules.
%    backprop - Backpropagation networks.
%    elman    - Elman recurrent networks.
%    hopfield - Hopfield recurrent networks.
%    linnet   - Linear networks.
%    lvq      - Learning vector quantization.
%    percept  - Perceptrons.
%    radbasis - Radial basis networks.
%    selforg  - Self-organizing networks.
%-------------------------------------------
%
%  Neural Network Demonstrations.
% 
%  Neural Network Toolbox Demonstrations and Applications
%  ------------------------------------------------------
% 
%  Perceptrons
%    demop1   - Classification with a 2-input perceptron.
%    demop4   - Outlier input vectors.
%    demop5   - Normalized perceptron rule
%    demop6   - Linearly non-separable vectors.
%  
%  Adaptive Linear Filters
%    demolin1 - Pattern association showing error surface.
%    demolin2 - Training a linear neuron.
%    demolin4 - Linear fit of nonlinear problem.
%    demolin5 - Underdetermined problem.
%    demolin6 - Linearly dependent problem.
%    demolin7 - Too large a learning rate. 
%    demolin8 - Adaptive noise cancellation.
% 
%  Backpropagation - See Neural Network Design Demos below.
% 
%  Radial Basis Networks
%    demorb1  - Radial basis approximation.
%    demorb3  - Radial basis underlapping neurons.
%    demorb4  - Radial basis overlapping neurons.
%    demogrn1 - GRNN function approximation.
%    demopnn1 - PNN classification.
% 
%  Self-Organizing Maps
%    democ1   - Competitive learning.
%    demosm1  - One-dimensional self-organizing map.
%    demosm2  - Two-dimensional self-organizing map.
% 
%  Learning Vector Quantization
%    demolvq1 - Learning vector quantization.
% 
%  Recurrent Networks
%    demohop1 - Hopfield two neuron design.
%    demohop2 - Hopfield unstable equilibria.
%    demohop3 - Hopfield three neuron design.
%    demohop4 - Hopfield spurious stable points.
% 
%  Applications
%    applin1  - Linear design.
%    applin2  - Adaptive linear prediction.
%    applin3  - Linear system identification.
%    applin4  - Adaptive linear system identification.
%    appelm1  - Elman amplitude detection
%    appcs1   - Nonlinear control system identification.
%    appcs2   - Model reference control.
%    appcr1   - Character recognition.
% 
%  Neural Network Design Textbook Demonstrations.
%  Copyright (c) 1994-1998 by PWS Publishing Company.
%  Used by permission.
%  ---------------------------------------------
%  General
%    nnd      - Splash screen.
%    nndtoc   - Table of contents.
%    nnsound  - Turn Neural Network Design sounds on and off.
% 
%  Chapter 2, Neuron Model and Network Architectures
%    nnd2n1   - One-input neuron demonstration.
%    nnd2n2   - Two-input neuron demonstration.
% 
%  Chapter 3, An Illustrative Example
%    nnd3pc   - Perceptron classification demonstration.
%    nnd3hamc - Hamming classification demonstration.
%    nnd3hopc - Hopfield classification demonstration.
% 
%  Chapter 4, Perceptron Learning Rule
%    nnd4db   - Decision boundaries demonstration.+
%    nnd4pr   - Perceptron rule demonstration.+
% 
%  Chapter 5, Signal and Weight Vector Spaces
%    nnd5gs   - Gram-Schmidt demonstration.
%    nnd5rb   - Reciprocal basis demonstration.
% 
%  Chapter 6, Linear Transformations for Neural Networks
%    nnd6lt   - Linear transformations demonstration.
%    nnd6eg   - Eigenvector game.
% 
%  Chapter 7, Supervised Hebbian Learning
%    nnd7sh   - Supervised Hebb demonstration.
% 
%  Chapter 8, Performance Surfaces and Optimum Points
%    nnd8ts1  - Taylor series demonstration #1.
%    nnd8ts2  - Taylor series demonstration #2.
%    nnd8dd   - Directional derivatives demonstration.
%    nnd8qf   - Quadratic function demonstration.
% 
%  Chapter 9, Performance Optimization
%    nnd9sdq  - Steepest descent for quadratic function demonstration.
%    nnd9mc   - Method comparison demonstration.
%    nnd9nm   - Newton's method demonstration.
%    nnd9sd   - Steepest descent demonstration.
% 
%  Chapter 10, Widrow-Hoff Learning
%    nnd10nc  - Adaptive noise cancellation demonstration.
%    nnd10eeg - Electroencephelogram noise cancellation demonstration.
%    nnd10lc  - Linear pattern classification demonstration.
% 
%  Chapter 11, Backpropagation
%    nnd11nf  - Network function demonstration.
%    nnd11bc  - Backpropagation calculation demonstration.
%    nnd11fa  - Function approximation demonstration.
%    nnd11gn  - Generalization demonstration.
% 
%  Chapter 12, Variations on Backpropagation
%    nnd12sd1 - Steepest descent backpropagation demonstration #1.
%    nnd12sd2 - Steepest descent backpropagation demonstration #2.
%    nnd12mo  - Momentum backpropagation demonstration.
%    nnd12vl  - Variable learning rate backpropagation demonstration.
%    nnd12ls  - Conjugate gradient line search demonstration.
%    nnd12cg  - Conjugate gradient backpropagation demonstration.
%    nnd12ms  - Marquardt step demonstration.
%    nnd12m   - Marquardt backpropagation demonstration.
% 	
%  Chapter 13, Associative Learning
%    nnd13uh  - Unsupervised Hebb demonstration.
%    nnd13edr - Effects of decay rate demonstration.
%    nnd13hd  - Hebb with decay demonstration.
%    nnd13gis - Graphical instar demonstration.
%    nnd13is  - Instar demonstration.
%    nnd13os  - Outstar demonstration.
% 
%  Chapter 14, Competitive Networks
%    nnd14cc  - Competitive classification demonstration.
%    nnd14cl  - Competitive learning demonstration.
%    nnd14fm1 - 1-D Feature map demonstration.
%    nnd14fm2 - 2-D Feature map demonstration.
%    nnd14lv1 - LVQ1 demonstration.
%    nnd14lv2 - LVQ2 demonstration.
% 
%  Chapter 15, Grossberg Network
%    nnd15li  - Leaky integrator demonstration.
%    nnd15sn  - Shunting network demonstration.
%    nnd15gl1 - Grossberg layer 1 demonstration.
%    nnd15gl2 - Grossberg layer 2 demonstration.
%    nnd15aw  - Adaptive weights demonstration.
% 
%  Chapter 16, Adaptive Resonance Theory
%    nnd16al1 - ART1 layer 1 demonstration.
%    nnd16al2 - ART1 layer 2 demonstration.
%    nnd16os  - Orienting subsystem demonstration.
%    nnd16a1  - ART1 algorithm demonstration.
% 
%  Chapter 17, Stability
%    nnd17ds  - Dynamical system demonstration.
% 
%  Chapter 18, Hopfield Network
%    nnd18hn  - Hopfield network demonstration.
% 
%  Custom Functions
%  ----------------
% 
%  Custom simulation functions.
%    mytf     - Example custom transfer function.
%    mydtf    - Example custom transfer derivative function of MYTF.
%    mynif    - Example custom net input function.
%    mydnif   - Example custom transfer derivative function of MYNIF.
%    mywf     - Example custom weight function.
%    mydwf    - Example custom weight derivative function of MYWF.
% 
%  Custom initialization functions.
%    mywbif   - Example custom weight and bias initialization function.
% 
%  Custom learning functions.
%    mypf     - Example custom performance function.
%    mydpf    - Example custom performance derivative function for MYPF.
%    mywblf   - Example custom weight and bias learning function.
% 
%  Custom self-organizing map functions.
%    mydistf  - Example custom distance function.
%    mytopf   - Example custom topology function.
% 
%  Copyright (c) 1992-1998 by The MathWorks, Inc.
%  $Revision: 1.11 $
%

function adaptwb
%MATLAB Tour Partial Function Help:  nnt_con
%
% ADAPTWB By-weight-and-bias network adaption function.
% 
% 	Syntax
% 
% 	  [net,Ac,El] = adaptwb(net,Pd,T,Ai,Q,TS)
% 	  info = adaptwb(code)
% 
% 	Description
% 
% 	  ADAPTWB is a network adapt function which updates each
% 	  weight and bias according to its learning function.
% 
% 	  ADAPTWB takes these inputs:
% 	    NET - Neural network.
% 	    Pd  - Delayed inputs.
% 	    Tl  - Layer targets.
% 	    Ai  - Initial input conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	  and after training the network with its weight and bias
% 	  learning functions returns:
% 	    NET - Updated network.
% 	    Ac  - Collective layer outputs.
% 	    El  - Layer errors.
% 
% 	  Adaption occurs according to the ADAPTWB's training parameter,
% 	  shown here with its default value:
% 	    net.adaptParam.passes  1  Number of passes through sequence
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a ZijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is an VixQ matrix or [].
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	    Ac - Nlx(LD+TS) cell array, each element Ac{i,k} is an SixQ matrix.
% 	    El - NlxTS cell array, each element El{i,k} is an SixQ matrix or [].
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Zij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  ADAPTWB(CODE) return useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses ADAPTWB by calling
% 	  NEWP or NEWLIN.
% 
% 	  To prepare a custom network to adapt with ADAPTWB:
% 	  1) Set NET.adaptFcn to 'adaptwb'.
% 	     (This will set NET.adaptParam to ADAPTWB's default parameters.)
% 	  2) Set each NET.inputWeights{i,j}.learnFcn to a learning function.
% 	     Set each NET.layerWeights{i,j}.learnFcn to a learning function.
% 	     Set each NET.biases{i}.learnFcn to a learning function.
% 	     (Weight and bias learning parameters will automatically be
% 	     set to default values for the given learning function.)
% 
% 	  To allow the network to adapt:
% 	  1) Set NET.adaptParam properties to desired values.
% 	  2) Set weight and bias learning parameters to desired values.
% 	  3) Call ADAPT.
% 
% 	  See NEWP and NEWLIN for adaption examples.
% 
% 	Algorithm
% 
% 	  Each weight and bias is updated according to its learning function
% 	  after each step in the input sequence.
% 
% 	

function errsurf
%MATLAB Tour Partial Function Help:  nnt_con
%
% ERRSURF Error surface of single input neuron.
% 
% 	Syntax
% 
% 	  e = errsurf(p,t,wv,bv,f)
% 
% 	Description
% 	
% 	  ERRSURF(P,T,WV,BV,F) takes these arguments,
% 	    P  - 1xQ matrix of input vectors.
% 	    T  - 1xQ matrix of target vectors.
% 	    WV - Row vector of values of W.
% 	    BV - Row vector of values of B.
% 	    F  - Transfer function (string).
% 	  and returns a matrix of error values over WV and BV.
% 	       
% 	Examples
% 
% 	  p = [-6.0 -6.1 -4.1 -4.0 +4.0 +4.1 +6.0 +6.1];
% 	  t = [+0.0 +0.0 +.97 +.99 +.01 +.03 +1.0 +1.0];
% 	  wv = -1:.1:1; bv = -2.5:.25:2.5;
% 	  es = errsurf(p,t,wv,bv,'logsig');
% 	  plotes(wv,bv,es,[60 30])
% 
% 	

function maxlinlr
%MATLAB Tour Partial Function Help:  nnt_con
%
% MAXLINLR Maximum learning rate for a linear layer.
% 
% 	Syntax
% 
% 	  lr = maxlinlr(P)
% 	  lr = maxlinlr(P,'bias')
% 
% 	Description
% 
% 	  MAXLINLR is used to calculate learning rates for NEWLIN.
% 	
% 	  MAXLINLR(P) takes one argument,
% 	    P - RxQ matrix of input vectors.
% 	  and returns the maximum learning rate for a linear layer
% 	  without a bias that is to be trained only on the vectors in P.
% 
% 	  MAXLINLR(P,'bias') return the maximum learning rate for
% 	  a linear layer with a bias.
% 	
% 	Examples
% 
% 	  Here we define a batch of 4 2-element input vectors and
% 	  find the maximum learning rate for a linear layer with
% 	  a bias.
% 
% 	    P = [1 2 -4 7; 0.1 3 10 6];
% 	    lr = maxlinlr(P,'bias')
% 	
% 	

function boxdist
%MATLAB Tour Partial Function Help:  nnt_con
%
% BOXDIST Box distance function.
% 
% 	Syntax
% 
% 	  d = boxdist(pos);
% 
% 	Description
% 
% 	  BOXDIST is a layer distance function used to find
% 	  the distances between the layer's neurons given their
% 	  positions.
% 
% 	  BOXDIST(pos) takes one argument,
% 	    POS - NxS matrix of neuron positions.
%      and returns the SxS matrix of distances.
% 
% 	  BOXDIST is most commonly used in conjunction with layers
% 	  whose topology function is GRIDTOP.
% 
% 	Examples
% 
% 	  Here we define a random matrix of positions for 10 neurons
% 	  arranged in three dimensional space and find their distances.
% 
% 	    pos = rand(3,10);
% 	    d = boxdist(pos)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses BOXDIST
% 	  as a distance function by calling NEWSOM.
% 
% 	  To change a network so a layer's topology uses BOXDIST set
% 	  NET.layers{i}.distanceFcn to 'boxdist'.
% 
% 	  In either case, call SIM to simulate the network with BOXDIST.
% 	  See NEWSOM for training and adaption examples.
% 
% 	Algorithm
% 
% 	  The box distance D between two position vectors Pi and Pj
% 	  from a set of S vectors is:
% 	
% 	    Dij = max(abs(Pi-Pj))
% 
% 	

function dist
%MATLAB Tour Partial Function Help:  nnt_con
%
% DIST Euclidean distance weight function.
% 
% 	Syntax
% 
% 	  Z = dist(W,P)
% 	  df = dist('deriv')
% 	  D = dist(pos)
% 
% 	Description
% 
% 	  DIST is the Euclidean distance weight function. Weight
% 	  functions apply weights to an input to get weighted inputs.
% 
% 	  DIST(W,P) takes these inputs,
% 	    W - SxR weight matrix.
% 	    P - RxQ matrix of Q input (column) vectors.
% 	  and returns the SxQ matrix of vector distances.
% 
% 	  DIST('deriv') returns '' because DIST does not have
% 	  a derivative function.
% 
% 	  DIST is also a layer distance function which can be used
% 	  to find the distances between neurons in a layer.
% 
% 	  DIST(POS) takes one argument,
% 	    POS - NxS matrix of neuron positions.
%      and returns the SxS matrix of distances.
% 
% 	Examples
% 
% 	  Here we 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 = dist(W,P)
% 
% 	  Here we 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)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses DIST
% 	  by calling NEWPNN or NEWGRNN.
% 
% 	  To change a network so an input weight uses DIST set
% 	  NET.inputWeight{i,j}.weightFcn to 'dist.  For a layer weight
% 	  set NET.inputWeight{i,j}.weightFcn to 'dist'.
% 
% 	  To change a network so that a layer's topology uses DIST set
% 	  NET.layers{i}.distanceFcn to 'dist'.
% 
% 	  In either case, call SIM to simulate the network with DIST.
% 	  See NEWPNN or NEWGRNN for simulation examples.
% 
% 	Algorithm
% 
% 	  The Euclidean distance D between two vectors X and Y is:
% 	
% 	    D = sum((x-y).^2).^0.5
% 
% 	

function mandist
%MATLAB Tour Partial Function Help:  nnt_con
%
% MANDIST Manhattan distance weight function.
% 
% 	Syntax
% 
% 	  Z = mandist(W,P)
% 	  df = mandist('deriv')
% 	  D = mandist(pos);
% 
% 	Description
% 
% 	  MANDIST is the Manhattan distance weight function. Weight
% 	  functions apply weights to an input to get weighted inputs.
% 
% 	  MANDIST(W,P) takes these inputs,
% 	    W - SxR weight matrix.
% 	    P - RxQ matrix of Q input (column) vectors.
% 	  and returns the SxQ matrix of vector distances.
% 
% 	  MANDIST('deriv') returns '' because MANDIST does not have
% 	  a derivative function.
% 
% 	  MANDIST is also a layer distance function which can be used
% 	  to find distances between neurons in a layer.
% 
% 	  MANDIST(POS) takes one argument,
% 	    POS - S row matrix of neuron positions.
%      and returns the SxS matrix of distances.
% 
% 	Examples
% 
% 	  Here we 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 we 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
% 
% 	  You can create a standard network that uses MANDIST
% 	  as a distance function by calling NEWSOM.
% 
% 	  To change a network so an input weight uses MANDIST set
% 	  NET.inputWeight{i,j}.weightFcn to 'mandist.  For a layer weight
% 	  set NET.inputWeight{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.
% 
% 	Algorithm
% 
% 	  The Manhattan distance D between two vectors X and Y is:
% 	
% 	    D = sum(abs(x-y))
% 
% 	

function linkdist
%MATLAB Tour Partial Function Help:  nnt_con
%
% LINKDIST Link distance function.
% 
% 	Syntax
% 
% 	  d = linkdist(pos);
% 
% 	Description
% 
% 	  LINKDIST is a layer distance function used to find
% 	  the distances between the layer's neurons given their
% 	  positions.
% 
% 	  LINKDIST(pos) takes one argument,
% 	    POS - NxS matrix of neuron positions.
%      and returns the SxS matrix of distances.
% 
% 	Examples
% 
% 	  Here we define a random matrix of positions for 10 neurons
% 	  arranged in three dimensional space and find their distances.
% 
% 	    pos = rand(3,10);
% 	    D = linkdist(pos)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LINKDIST
% 	  as a distance function by calling NEWSOM.
% 
% 	  To change a network so a layer's topology uses LINKDIST set
% 	  NET.layers{i}.distanceFcn to 'linkdist'.
% 
% 	  In either case, call SIM to simulate the network with DIST.
% 	  See NEWSOM for training and adaption examples.
% 
% 	Algorithm
% 
% 	  The link distance D between two position vectors Pi and Pj
% 	  from a set of S vectors is:
% 	
% 	    Dij = 0, if i==j
% 	        = 1, if sum((Pi-Pj).^2).^0.5 is <= 1
% 	        = 2, if k exists, Dik = Dkj = 1
% 	        = 3, if k1, k2 exist, Dik1 = Dk1k2 = Dk2j = 1.
% 	        = N, if k1..kN exist, Dik1 = Dk1k2 = ...= DkNj = 1
%            = S, if none of the above conditions apply.
% 
% 	

function initnw
%MATLAB Tour Partial Function Help:  nnt_con
%
% INITNW Nguyen-Widrow layer initialization function.
% 
% 	Syntax
% 
% 	  net = initnw(net,i)
% 
% 	Description
% 
% 	  INITNW is a layer initialization function which initializes
% 	  a layer's weights and biases according to the Nguyen-Widrow
% 	  initialization algorithm.  This algorithm chooses values in order
% 	  to distribute the active region of each neuron in the layer
% 	  evenly across the layer's input space.
% 
% 	  INITNW(NET,i) takes two arguments,
% 	    NET - Neural network.
% 	    i   - Index of a layer.
% 	  and returns the network with layer i's weights and biases updated.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses INITNW by calling
% 	  NEWFF or NEWCF.
% 
% 	  To prepare a custom network to be initialized with INITNW:
% 	  1) Set NET.initFcn to 'initlay'.
% 	     (This will set NET.initParam to the empty matrix [] since
% 	     INITLAY has no initialization parameters.)
% 	  2) Set NET.layers{i}.initFcn to 'initnw'.
% 
% 	  To initialize the network call INIT.
% 
% 	  See NEWFF and NEWCF for training examples.
% 
% 	Algorithm
% 
% 	  The Nguyen-Widrow method generates initial weight and bias
% 	  values for a layer so that the active regions of the layer's
% 	  neurons will be distributed roughly evenly over the input space.
% 
% 	  Advantages over purely random weights and biases are:
% 	  (1) Few neurons are wasted (since all the neurons are in the input space).
% 	  (2) Training works faster (since each area of the input space has neurons).
% 
% 	  The Nguyen-Widrow method can only be applied to layers...
% 	  ...with a bias,
% 	  ...with weights whose "weightFcn" is DOTPROD,
% 	  ...with "netInputFcn" set to NETSUM.
% 	  If these conditions are not met then INITNW uses RANDS to
% 	  initialize the layer's weights and biases.
% 
% 	

function initwb
%MATLAB Tour Partial Function Help:  nnt_con
%
% INITWB By-weight-and-bias layer initialization function.
% 
% 	Syntax
% 
% 	  net = initwb(net,i)
% 	
% 	Description
% 
% 	  INITWB is a layer initialization function which initializes
% 	  a layer's weights and biases according to their own initialization
% 	  functions.
% 
% 	  INITWB(NET,i) takes two arguments,
% 	    NET - Neural network.
% 	    i   - Index of a layer.
% 	  and returns the network with layer i's weights and biases updated.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses INITWB by calling
% 	  NEWP or NEWLIN.
% 
% 	  To prepare a custom network to be initialized with INITWB:
% 	  1) Set NET.initFcn to 'initlay'.
% 	     (This will set NET.initParam to the empty matrix [] since
% 	     INITLAY has no initialization parameters.)
% 	  2) Set NET.layers{i}.initFcn to 'initwb'.
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to a weight initialization function.
% 	     Set each NET.layerWeights{i,j}.learnFcn to a weight initialization function.
% 	     Set each NET.biases{i}.learnFcn to a bias initialization function.
% 	     (Examples of such functions are RANDS and MIDPOINT.)
% 
% 	  To initialize the network call INIT.
% 
% 	  See NEWP and NEWLIN for training examples.
% 
% 	Algorithm
% 
% 	  Each weight (bias) in layer i is set to new values calculated
% 	  according to its weight (bias) initialization function.
% 
% 	

function learncon
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNCON Conscience bias learning function.
% 
% 	Syntax
% 	
% 	  [dB,LS] = learncon(B,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learncon(code)
% 
% 	Description
% 
% 	  LEARNCON is the conscience bias learning function
% 	  used to increase the net input to neurons which
% 	  have the lowest average output until each neuron
% 	  responds roughly an equal percentage of the time.
% 
% 	  LEARNCON(B,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    B  - Sx1 bias vector.
% 	    P  - 1xQ ones vector.
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns
% 	    dB - Sx1 weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNCON's learning parameter,
% 	  shown here with its default value.
% 	    LP.lr - 0.001 - Learning rate
% 
% 	  LEARNCON(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	  NNT 2.0 compatibility: The LP.lr described above equals
% 	  1 minus the bias time constant used by TRAINC in NNT 2.0.
% 
% 	Examples
% 
% 	  Here we define a random output A, and bias vector W for a
% 	  layer with 3 neurons.  We also define the learning rate LR.
% 
% 	    a = rand(3,1);
% 	    b = rand(3,1);
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNCON only needs these values to calculate a bias
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learncon(b,[],[],[],a,[],[],[],[],[],lp,[])
% 
% 	Network Use
% 
% 	  To prepare the bias of layer i of a custom network
% 	  to learn with LEARNCON:
% 	  1) Set NET.trainFcn to 'trainwb1'.
% 	     (NET.trainParam will automatically become TRAINWB1's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB1's default parameters.)
% 	  3) Set NET.inputWeights{i}.learnFcn to 'learncon'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learncon'.
% 	     (Each weight learning parameter property will automatically
% 	     be set to LEARNCON's default parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (or NET.adaptParam) properties as desired.
% 	  2) Call TRAIN (or ADAPT).
% 
% 	Algorithm
% 
% 	  LEARNCON calculates the bias change db for a given neuron
% 	  by first updating each neuron's "conscience", i.e. the
% 	  running average of its output:
% 
% 	    c = (1-lr)*c + lr*a
% 
% 	  The conscience is then used to compute a bias for the
% 	  neuron that is greatest for smaller conscience values.
% 
% 	    b = exp(1-log(c)) - b
% 
% 	  (Note that LEARNCON is able to recover C each time it
%      is called from the bias values.)
% 
% 	

function learngd
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNGD Gradient descent weight/bias learning function.
% 	
% 	Syntax
% 	
% 	  [dW,LS] = learngd(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  [db,LS] = learngd(b,ones(1,Q),Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learngd(code)
% 
% 	Description
% 
% 	  LEARNGD is the gradient descent weight/bias learning function.
% 	
% 	  LEARNGD(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNGD's learning parameter
% 	  shown here with its default value.
% 	    LP.lr - 0.01 - Learning rate
% 
% 	  LEARNGD(CODE) return useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random gradient gW for a weight going
% 	  to a layer with 3 neurons, from an input with 2 elements.
% 	  We also define a learning rate of 0.5.
% 
% 	    gW = rand(3,2);
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNGD only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learngd([],[],[],[],[],[],[],gW,[],[],lp,[])
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LEARNGD with NEWFF,
% 	  NEWCF, or NEWELM.
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to adapt with LEARNGD:
% 	  1) Set NET.adaptFcn to 'adaptwb'.
% 	     NET.adaptParam will automatically become TRAINWB's default parameters.
% 	  2) Set each NET.inputWeights{i,j}.learnFcn to 'learngd'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learngd'.
% 	     Set NET.biases{i}.learnFcn to 'learngd'.
% 	     Each weight and bias learning parameter property will automatically
% 	     be set to LEARNGD's default parameters.
% 
% 	  To allow the network to adapt:
% 	  1) Set NET.adaptParam properties to desired values.
% 	  2) Call ADAPT with the network.
% 
% 	  See NEWFF or NEWCF for examples.
% 	  
% 	Algorithm
% 
% 	  LEARNGD calculates the weight change dW for a given neuron from
% 	  the neuron's input P and error E, and the weight (or bias) learning
% 	  rate LR, according to the gradient descent:
% 
% 	    dw = lr*gW
% 
% 	

function learngdm
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNGDM Gradient descent w/momentum weight/bias learning function.
% 	
% 	Syntax
% 	
% 	  [dW,LS] = learngdm(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  [db,LS] = learngdm(b,ones(1,Q),Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learngdm(code)
% 
% 	Description
% 
% 	  LEARNGDM is the gradient descent with momentum weight/bias
% 	  learning function.
% 	
% 	  LEARNGDM(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNGDM's learning parameters,
% 	  shown here with their default values.
% 	    LP.lr - 0.01 - Learning rate
% 	    LP.mc - 0.9  - Momentum constant
% 
% 	  LEARNGDM(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random gradient G for a weight going
% 	  to a layer with 3 neurons, from an input with 2 elements.
% 	  We also define a learning rate of 0.5 and momentum constant
% 	  of 0.8;
% 
% 	    gW = rand(3,2);
% 	    lp.lr = 0.5;
% 	    lp.mc = 0.8;
% 
% 	  Since LEARNGDM only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 	  We will use the default initial learning state.
%  
% 	    ls = [];
% 	    [dW,ls] = learngdm([],[],[],[],[],[],[],gW,[],[],lp,ls)
% 
% 	  LEARNGDM returns the weight change and a new learning state.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LEARNGD with NEWFF,
% 	  NEWCF, or NEWELM.
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to adapt with LEARNGDM:
% 	  1) Set NET.adaptFcn to 'adaptwb'.
% 	     NET.adaptParam will automatically become TRAINWB's default parameters.
% 	  2) Set each NET.inputWeights{i,j}.learnFcn to 'learngdm'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learngdm'.
% 	     Set NET.biases{i}.learnFcn to 'learngdm'.
% 	     Each weight and bias learning parameter property will automatically
% 	     be set to LEARNGDM's default parameters.
% 
% 	  To allow the network to adapt:
% 	  1) Set NET.adaptParam properties to desired values.
% 	  2) Call ADAPT with the network.
% 
% 	  See NEWFF or NEWCF for examples.
% 	  
% 	Algorithm
% 
% 	  LEARNGDM calculates the weight change dW for a given neuron
% 	  from the neuron's input P and error E, the weight (or bias)
% 	  learning rate LR, and momentum constant MC, according to
% 	  gradient descent with momentum:
% 
% 	    dW = mc*dWprev + (1-mc)*lr*gW
% 
% 	  The previous weight change dWprev is stored and read
% 	  from the learning state LS.
% 
% 	

function learnh
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNH Hebb weight learning rule.
% 
% 	Syntax
% 	
% 	  [dW,LS] = learnh(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnh(code)
% 
% 	Description
% 
% 	  LEARNH is the Hebb weight learning function.
% 
% 	  LEARNH(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNH's learning parameter,
% 	  shown here with its default value.
% 	    LP.lr - 0.01 - Learning rate
% 
% 	  LEARNH(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P and output A for a layer
% 	  with a 2-element input and 3 neurons.  We also define the
% 	  learning rate LR.
% 
% 	    p = rand(2,1);
% 	    a = rand(3,1);
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNH only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnh([],p,[],[],a,[],[],[],[],[],lp,[])
% 
% 	Network Use
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to learn with LEARNH:
% 	  1) Set NET.trainFcn to 'trainwb'.
% 	     (NET.trainParam will automatically become TRAINWB's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB's default parameters.)
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnh'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnh'.
% 	     (Each weight learning parameter property will automatically
% 	     be set to LEARNH's default parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (NET.adaptParam) properties to desired values.
% 	  2) Call TRAIN (ADAPT).
% 
% 	Algorithm
% 
% 	  LEARNH calculates the weight change dW for a given neuron from the
% 	  neuron's input P, output A, and learning rate LR according to the
% 	  Hebb learning rule:
% 
% 	    dw =  lr*a*p'
% 
% 	

function learnhd
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNHD Hebb with decay weight learning rule.
% 
% 	Syntax
% 	
% 	  [dW,LS] = learnhd(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnhd(code)
% 
% 	Description
% 
% 	  LEARNHD is the Hebb weight learning function.
% 
% 	  LEARNHD(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNHD's learning parameters
% 	  shown here with default values.
% 	    LP.dr - 0.01 - Decay rate.
% 	    LP.lr - 0.1  - Learning rate
% 
% 	  LEARNHD(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P, output A, and weights W
% 	  for a layer with a 2-element input and 3 neurons.  We also
% 	  define the decay and learning rates.
% 
% 	    p = rand(2,1);
% 	    a = rand(3,1);
% 	    w = rand(3,2);
% 	    lp.dr = 0.05;
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNHD only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnhd(w,p,[],[],a,[],[],[],[],[],lp,[])
% 
% 	Network Use
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to learn with LEARNHD:
% 	  1) Set NET.trainFcn to 'trainwb'.
% 	     (NET.trainParam will automatically become TRAINWB's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB's default parameters.)
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnhd'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnhd'.
% 	     (Each weight learning parameter property will automatically
% 	     be set to LEARNHD's default parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (NET.adaptParam) properties to desired values.
% 	  2) Call TRAIN (ADAPT).
% 
% 	Algorithm
% 
% 	  LEARNHD calculates the weight change dW for a given neuron from the
% 	  neuron's input P, output A, decay rate DR, and learning rate LR
% 	  according to the Hebb with decay learning rule:
% 
% 	    dw =  lr*a*p' - dr*w
% 
% 	

function learnis
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNIS Instar weight learning function.
% 
% 	Syntax
% 	
% 	  [dW,LS] = learnis(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnis(code)
% 
% 	Description
% 
% 	  LEARNIS is the instar weight learning function.
% 
% 	  LEARNIS(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNIS's learning parameter,
% 	  shown here with its default value.
% 	    LP.lr - 0.01 - Learning rate
% 
% 	  LEARNIS(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P, output A, and weight matrix W
% 	  for a layer with a 2-element input and 3 neurons.  We also define
% 	  the learning rate LR.
% 
% 	    p = rand(2,1);
% 	    a = rand(3,1);
% 	    w = rand(3,2);
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNIS only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnis(w,p,[],[],a,[],[],[],[],[],lp,[])
% 
% 	Network Use
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  so that it can learn with LEARNIS:
% 	  1) Set NET.trainFcn to 'trainwb'.
% 	     (NET.trainParam will automatically become TRAINWB's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB's default parameters.)
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnis'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnis'.
% 	     (Each weight learning parameter property will automatically
% 	     be set to LEARNIS's default parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (NET.adaptParam) properties to desired values.
% 	  2) Call TRAIN (ADAPT).
% 
% 	Algorithm
% 
% 	  LEARNIS calculates the weight change dW for a given neuron from the
% 	  neuron's input P, output A, and learning rate LR according to the
% 	  instar learning rule:
% 
% 	    dw =  lr*a*(p'-w)
% 
% 	

function learnk
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNK Kohonen weight learning function.
% 
% 	Syntax
% 	
% 	  [dW,LS] = learnk(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnk(code)
% 
% 	Description
% 
% 	  LEARNK is the Kohonen weight learning function.
% 
% 	  LEARNK(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNK's learning parameter,
% 	  shown here with its default value.
% 	    LP.lr - 0.01 - Learning rate
% 
% 	  LEARNK(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P, output A, and weight matrix W
% 	  for a layer with a 2-element input and 3 neurons.  We also define
% 	  the learning rate LR.
% 
% 	    p = rand(2,1);
% 	    a = rand(3,1);
% 	    w = rand(3,2);
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNK only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnk(w,p,[],[],a,[],[],[],[],[],lp,[])
% 
% 	Network Use
% 
% 	  To prepare the weights of layer i of a custom network
% 	  to learn with LEARNK:
% 	  1) Set NET.trainFcn to 'trainwb1'.
% 	     (NET.trainParam will automatically become TRAINWB1's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB1's default parameters.)
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnk'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnk'.
% 	     (Each weight learning parameter property will automatically
% 	     be set to LEARNK's default parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (or NET.adaptParam) properties as desired.
% 	  2) Call TRAIN (or ADAPT).
% 
% 	Algorithm
% 
% 	  LEARNK calculates the weight change dW for a given neuron from
% 	  the neuron's input P, output A, and learning rate LR according
% 	  to the Kohenen learning rule:
% 
% 	    dw =  lr*(p'-w), if a ~= 0
% 	       =  0, otherwise
% 
% 	

function learnlv1
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNLV1 LVQ1 weight learning function.
% 
% 	Syntax
% 	
% 	  [dW,LS] = learnlv1(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnlv1(code)
% 
% 	Description
% 
% 	  LEARNLV1 is the LVQ1 weight learning function.
% 
% 	  LEARNLV1(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR weight gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNLV1's learning parameter,
% 	  shown here with its default value.
% 	    LP.lr - 0.01 - Learning rate
% 
% 	  LEARNLV1(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P, output A, weight matrix W, and
% 	  output gradient gA for a layer with a 2-element input and 3 neurons.
% 	  We also define the learning rate LR.
% 
% 	    p = rand(2,1);
% 	    w = rand(3,2);
% 	    a = compet(negdist(w,p));
% 	    gA = [-1;1; 1];
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNLV1 only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnlv1(w,p,[],[],a,[],[],[],gA,[],lp,[])
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LEARNLV1 with NEWLVQ.
% 
% 	  To prepare the weights of layer i of a custom network
% 	  to learn with LEARNLV1:
% 	  1) Set NET.trainFcn to 'trainwb1'.
% 	     (NET.trainParam will automatically become TRAINWB1's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB1's default parameters.)
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnlv1'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnlv1'.
% 	     (Each weight learning parameter property will automatically
% 	     be set to LEARNLV1's default parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (or NET.adaptParam) properties as desired.
% 	  2) Call TRAIN (or ADAPT).
% 
% 	Algorithm
% 
% 	  LEARNLV1 calculates the weight change dW for a given neuron from
% 	  the neuron's input P, output A, output gradient gA and learning rate LR,
% 	  according to the LVQ1 rule, given i the index of the neuron whose
% 	  output a(i) is 1:
% 
% 	    dw(i,:) = +lr*(p-w(i,:)) if gA(i) = 0
% 	            = -lr*(p-w(i,:)) if gA(i) = -1
% 
% 	

function learnlv2
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNLV2 LVQ2 weight learning function.
% 
% 	Syntax
% 	
% 	  [dW,LS] = learnlv2(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnlv2(code)
% 
% 	Description
% 
% 	  LEARNLV2 is the LVQ2 weight learning function.
% 
% 	  LEARNLV2(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR weight gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNLV1's learning parameter,
% 	  shown here with its default value.
% 	    LP.lr - 0.01 - Learning rate
% 
% 	  LEARNLV2(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a sample input P, output A, weight matrix W, and
% 	  output gradient gA for a layer with a 2-element input and 3 neurons.
% 	  We also define the learning rate LR.
% 
% 	    p = rand(2,1);
% 	    w = rand(3,2);
% 	    n = negdist(w,p);
% 	    a = compet(n);
% 	    gA = [-1;1; 1];
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNLV2 only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnlv2(w,p,[],n,a,[],[],[],gA,[],lp,[])
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LEARNLV2 with NEWLVQ.
% 
% 	  To prepare the weights of layer i of a custom network
% 	  to learn with LEARNLV1:
% 	  1) Set NET.trainFcn to 'trainwb1'.
% 	     (NET.trainParam will automatically become TRAINWB1's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB1's default parameters.)
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnlv2'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnlv2'.
% 	     (Each weight learning parameter property will automatically
% 	     be set to LEARNLV2's default parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (or NET.adaptParam) properties as desired.
% 	  2) Call TRAIN (or ADAPT).
% 
% 	Algorithm
% 
% 	  LEARNLV2 calculates the weight change dW for a given neuron from
% 	  the neuron's input P, output A, output gradient gA and learning rate LR
% 	  according to the LVQ2 rule, given i the index of the neuron whose
% 	  output a(i) is 1:
% 
% 	    dw(i,:) = +lr*(p-w(i,:)) if gA(i) = 0
% 	            = -lr*(p-w(i,:)) if gA(i) = -1
% 
% 	  if gA(i) is -1 then the index j is found of the neuron with the
% 	  greatest net input n(k), from the neurons whose gA(k) is 1.  This
% 	  neuron's weights are updated as follows:
% 
% 	    dw(j,:) = +lr*(p-w(i,:))
% 
% 	

function learnos
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNOS Outstar weight learning function.
% 
% 	Syntax
% 	
% 	  [dW,LS] = learnos(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnos(code)
% 
% 	Description
% 
% 	  LEARNOS is the outstar weight learning function.
% 
% 	  LEARNOS(W,P,Z,N,A,T,E,G,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNOS's learning parameter,
% 	  shown here with its default value.
% 	    LP.lr - 0.01 - Learning rate
% 
% 	  LEARNOS(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P, output A, and weight matrix W
% 	  for a layer with a 2-element input and 3 neurons.  We also define
% 	  the learning rate LR.
% 
% 	    p = rand(2,1);
% 	    a = rand(3,1);
% 	    w = rand(3,2);
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNOS only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnos(w,p,[],[],a,[],[],[],[],[],lp,[])
% 
% 	Network Use
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to learn with LEARNOS:
% 	  1) Set NET.trainFcn to 'trainwb'.
% 	     (NET.trainParam will automatically become TRAINWB's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB's default parameters.)
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnos'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnos'.
% 	     (Each weight learning parameter property will automatically
% 	     be set to LEARNOS's default parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (NET.adaptParam) properties to desired values.
% 	  2) Call TRAIN (ADAPT).
% 
% 	Algorithm
% 
% 	  LEARNOS calculates the weight change dW for a given neuron
% 	  from the neuron's input P, output A, and learning rate LR
% 	  according to the outstar learning rule:
% 
% 	    dw =  lr*(a-w)*p'
% 
% 	

function learnp
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNP Perceptron weight/bias learning function.
% 
% 	Syntax
% 	
% 	  [dW,LS] = learnp(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  [db,LS] = learnp(b,ones(1,Q),Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnp(code)
% 
% 	Description
% 
% 	  LEARNP is the perceptron weight/bias learning function.
% 
% 	  LEARNP(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  LEARNP(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P and error E to a layer
% 	  with a 2-element input and 3 neurons.
% 
% 	    p = rand(2,1);
% 	    e = rand(3,1);
% 
% 	  Since LEARNP only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnp([],p,[],[],[],[],e,[],[],[],[],[])
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LEARNP with NEWP.
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to learn with LEARNP:
% 	  1) Set NET.trainFcn to 'trainwb'.
% 	     (NET.trainParam will automatically become TRAINWB's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB's default parameters.)
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnp'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnp'.
% 	     Set NET.biases{i}.learnFcn to 'learnp'.
% 	     (Each weight and bias learning parameter property will automatically
% 	     become the empty matrix since LEARNP has no learning parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (NET.adaptParam) properties to desired values.
% 	  2) Call TRAIN (ADAPT).
% 
% 	  See NEWP for adaption and training examples.
% 
% 	Algorithm
% 
% 	  LEARNP calculates the weight change dW for a given neuron from the
% 	  neuron's input P and error E according to the perceptron learning rule:
% 
% 	    dw =  0,  if e =  0
% 	       =  p', if e =  1
% 	       = -p', if e = -1
% 
% 	  This can be summarized as:
% 
% 	    dw = e*p'
% 
% 	

function learnpn
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNPN Normalized perceptron weight/bias learning function.
% 	
% 	Syntax
% 	
% 	  [dW,LS] = learnpn(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnpn(code)
% 
% 	Description
% 
% 	  LEARNPN is a weight/bias learning function.  It can result
% 	  in faster learning than LEARNP when input vectors have
% 	  widely varying magnitudes.
% 
% 	  LEARNPN(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  LEARNPN(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P and error E to a layer
% 	  with a 2-element input and 3 neurons.
% 
% 	    p = rand(2,1);
% 	    e = rand(3,1);
% 
% 	  Since LEARNPN only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnpn([],p,[],[],[],[],e,[],[],[],[],[])
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LEARNPN with NEWP.
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to learn with LEARNPN:
% 	  1) Set NET.trainFcn to 'trainwb'.
% 	     NET.trainParam will automatically become TRAINWB's default parameters.
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     NET.adaptParam will automatically become TRAINWB's default parameters.
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnpn'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnpn'.
% 	     Set NET.biases{i}.learnFcn to 'learnpn'.
% 	     Each weight and bias learning parameter property will automatically
% 	     become the empty matrix since LEARNPN has no learning parameters.
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (NET.adaptParam) properties to desired values.
% 	  2) Call TRAIN (ADAPT).
% 
% 	  See NEWP for adaption and training examples.
% 	  
% 	Algorithm
% 
% 	  LEARNPN calculates the weight change dW for a given neuron from the
% 	  neuron's input P and error E according to the normalized perceptron
% 	  learning rule:
% 
% 	    pn = p / sqrt(1 + p(1)^2 + p(2)^2) + ... + p(R)^2)
% 	    dw =  0,   if e =  0
% 	       =  pn', if e =  1
% 	       = -pn', if e = -1
% 
% 	  The expression for dW can be summarized as:
% 
% 	    dw = e*pn'
% 
% 	

function learnsom
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNSOM Self-organizing map weight learning function.
% 
% 	Syntax
% 	
% 	  [dW,LS] = learnk(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnk(code)
% 
% 	Description
% 
% 	  LEARNSOM is the self-organizing map weight learning function.
% 
% 	  LEARNSOM(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNSOM's learning parameter,
% 	  shown here with its default value.
% 	    LP.order_lr    -  0.9 - Ordering phase learning rate.
% 	    LP.order_steps - 1000 - Ordering phase steps.
% 	    LP.tune_lr     - 0.02 - Tuning phase learning rate.
% 	    LP.tune_nd     -    1 - Tuning phase neighborhood distance.
% 
% 	  LEARNSOM(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P, output A, and weight matrix W,
% 	  for a layer with a 2-element input and 6 neurons.  We also calculate
% 	  the positions and distances for the neurons which are arranged in a
% 	  2x3 hexagonal pattern. Then we define the four learning parameters.
% 
% 	    p = rand(2,1);
% 	    a = rand(6,1);
% 	    w = rand(6,2);
% 	    pos = hextop(2,3);
% 	    d = linkdist(pos);
% 	    lp.order_lr = 0.9;
% 	    lp.order_steps = 1000;
% 	    lp.tune_lr = 0.02;
% 	    lp.tune_nd = 1;
% 
% 	  Since LEARNSOM only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    ls = [];
% 	    [dW,ls] = learnsom(w,p,[],[],a,[],[],[],[],d,lp,ls)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LEARNSOM with NEWSOM.
% 
% 	  To prepare the weights of layer i of a custom network
% 	  to learn with LEARNSOM:
% 	  1) Set NET.trainFcn to 'trainwb1'.
% 	     (NET.trainParam will automatically become TRAINWB1's default parameters.)
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     (NET.adaptParam will automatically become TRAINWB1's default parameters.)
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnsom'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnsom'.
% 	     (Each weight learning parameter property will automatically
% 	     be set to LEARNSOM's default parameters.)
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (or NET.adaptParam) properties as desired.
% 	  2) Call TRAIN (or ADAPT).
% 
% 	Algorithm
% 
% 	  LEARNSOM calculates the weight change dW for a given neuron from
% 	  the neuron's input P, activation A2, and learning rate LR:
% 
% 	    dw =  lr*a2*(p'-w)
% 
% 	  where the activation A2 is found from the layer output A and
% 	  neuron distances D and the current neighborhood size ND:
% 
% 	    a2(i,q) = 1,   if a(i,q) = 1
% 	            = 0.5, if a(j,q) = 1 and D(i,j) <= nd
% 	            = 0,   otherwise
% 
% 	  The learning rate LR and neighborhood size NS are altered
% 	  through two phases: an ordering phase and a tuning phase.
% 
% 	  The ordering phase lasts as many steps as LP.order_steps.
% 	  During this phase LR is adjusted from LP.order_lr down to
% 	  LP.tune_lr, and ND is adjusted from the maximum neuron distance
% 	  down to 1.  It is during this phase that neuron weights are expected
% 	  to order themselves in the input space consistent with
% 	  the associated neuron positions.
% 
% 	  During the tuning phase LR decreases slowly from LP.tune_lr and
% 	  ND is always set to LP.tune_nd.  During this phase the weights are
% 	  expected to spread out relatively evenly over the input space while
% 	  retaining their topological order found during the ordering phase.
% 
% 	

function learnwh
%MATLAB Tour Partial Function Help:  nnt_con
%
% LEARNWH Widrow-Hoff weight/bias learning function.
% 	
% 	Syntax
% 	
% 	  [dW,LS] = learnwh(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  [db,LS] = learnwh(b,ones(1,Q),Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  info = learnwh(code)
% 
% 	Description
% 
% 	  LEARNWH is the Widrow-Hoff weight/bias learning function,
% 	  and is also known as the delta or least mean squared (LMS) rule.
% 	
% 	  LEARNWH(W,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	  and returns,
% 	    dW - SxR weight (or bias) change matrix.
% 	    LS - New learning state.
% 
% 	  Learning occurs according to LEARNWH's learning parameter,
% 	  shown here with its default value.
% 	    LP.lr - 0.01 - Learning rate
% 
% 	  LEARNWH(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Returns names of learning parameters.
% 	    'pdefaults' - Returns default learning parameters.
% 	    'needg'     - Returns 1 if this function uses gW or gA.
% 
% 	Examples
% 
% 	  Here we define a random input P and error E to a layer
% 	  with a 2-element input and 3 neurons.  We also define the
% 	  learning rate LR learning parameter.
% 
% 	    p = rand(2,1);
% 	    e = rand(3,1);
% 	    lp.lr = 0.5;
% 
% 	  Since LEARNWH only needs these values to calculate a weight
% 	  change (see Algorithm below), we will use them to do so.
% 
% 	    dW = learnwh([],p,[],[],[],[],e,[],[],[],lp,[])
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LEARNWH with NEWLIN.
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to learn with LEARNWH:
% 	  1) Set NET.trainFcn to 'trainwb'.
% 	     NET.trainParam will automatically become TRAINWB's default parameters.
% 	  2) Set NET.adaptFcn to 'adaptwb'.
% 	     NET.adaptParam will automatically become TRAINWB's default parameters.
% 	  3) Set each NET.inputWeights{i,j}.learnFcn to 'learnwh'.
% 	     Set each NET.layerWeights{i,j}.learnFcn to 'learnwh'.
% 	     Set NET.biases{i}.learnFcn to 'learnwh'.
% 	     Each weight and bias learning parameter property will automatically
% 	     be set to LEARNWH's default parameters.
% 
% 	  To train the network (or enable it to adapt):
% 	  1) Set NET.trainParam (NET.adaptParam) properties to desired values.
% 	  2) Call TRAIN (ADAPT).
% 
% 	  See NEWLIN for adaption and training examples.
% 	  
% 	Algorithm
% 
% 	  LEARNWH calculates the weight change dW for a given neuron from the
% 	  neuron's input P and error E, and the weight (or bias) learning
% 	  rate LR, according to the Widrow-Hoff learning rule:
% 
% 	    dw = lr*e*pn'
% 
% 	

function srchbac
%MATLAB Tour Partial Function Help:  nnt_con
%
% SRCHBAC One-dimensional minimization using backtracking.
% 
% 	Syntax
% 	
% 	  [a,gX,perf,retcode,delta,tol] = srchbac(net,X,Pd,Tl,Ai,Q,TS,dX,gX,perf,dperf,delta,tol,ch_perf)
% 
% 	Description
% 
% 	  SRCHBAC is a linear search routine.  It searches in a given direction
%      to locate the minimum of the performance function in that direction.
%      It uses a technique called backtracking.
% 
% 	SRCHBAC(NET,X,Pd,Tl,Ai,Q,TS,dX,gX,PERF,DPERF,DELTA,TOL,CH_PERF) takes these inputs,
% 	    NET     - Neural network.
% 	    X       - Vector containing current values of weights and biases.
% 	    Pd      - Delayed input vectors.
% 	    Tl      - Layer target vectors.
% 	    Ai      - Initial input delay conditions.
% 	    Q       - Batch size.
% 	    TS      - Time steps.
% 	    dX      - Search direction vector.
% 	    gX      - Gradient vector.
% 	    PERF    - Performance value at current X.
% 	    DPERF   - Slope of performance value at current X in direction of dX.
% 	    DELTA   - Initial step size.
% 	    TOL     - Tolerance on search.
% 	    CH_PERF - Change in performance on previous step.
% 	  and returns,
% 	    A       - Step size which minimizes performance.
% 	    gX      - Gradient at new minimum point.
% 	    PERF    - Performance value at new minimum point.
% 	    RETCODE - Return code which has three elements. The first two elements correspond to
%                  the number of function evaluations in the two stages of the search
% 	              The third element is a return code. These will have different meanings
%                  for different search algorithms. Some may not be used in this function.
%                    0 - normal; 1 - minimum step taken; 2 - maximum step taken;
%                    3 - beta condition not met.
% 	    DELTA   - New initial step size. Based on the current step size.
% 	    TOL     - New tolerance on search.
% 
% 	  Parameters used for the backstepping algorithm are:
% 	    alpha     - Scale factor which determines sufficient reduction in perf.
% 	    beta      - Scale factor which determines sufficiently large step size.
% 	    low_lim   - Lower limit on change in step size.
% 	    up_lim    - Upper limit on change in step size.
% 	    maxstep   - Maximum step length.
% 	    minstep   - Minimum step length.
% 	    scale_tol - Parameter which relates the tolerance tol to the initial step
%                    size delta. Usually set to 20.
%      The defaults for these parameters are set in the training function which
%      calls it.  See TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is an VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses SRCHBAC with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINCGF using
%      the line search function SRCHBAC:
% 	  1) Set NET.trainFcn to 'traincgf'.
% 	     This will set NET.trainParam to TRAINCGF's default parameters.
% 	  2) Set NET.trainParam.searchFcn to 'srchbac'.
% 
% 	  The SRCHBAC function can be used with any of the following
%      training functions: TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINCGF
%      network training function and the SRCHBAC search function are used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'traincgf');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
%        net.trainParam.searchFcn = 'srchbac';
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 
% 	Algorithm
% 
% 	  SRCHBAC locates the minimum of the performance function in
% 	  the search direction dX, using the backtracking algorithm 
% 	  described on page 126 and 328 of Dennis and Schnabel.
%      (Numerical Methods for Unconstrained Optimization and Nonlinear Equations 1983).
% 
% 	

function srchbre
%MATLAB Tour Partial Function Help:  nnt_con
%
% SRCHBRE One-dimensional interval location using Brent's method.
% 
% 	Syntax
% 	
% 	  [a,gX,perf,retcode,delta,tol] = srchbre(net,X,Pd,Tl,Ai,Q,TS,dX,gX,perf,dperf,delta,tol,ch_perf)
% 
% 	Description
% 
% 	  SRCHBRE is a linear search routine.  It searches in a given direction
%      to locate the minimum of the performance function in that direction.
%      It uses a technique called Brent's method.
% 
% 	SRCHBRE(NET,X,Pd,Tl,Ai,Q,TS,dX,gX,PERF,DPERF,DELTA,TOL,CH_PERF) takes these inputs,
% 	    NET     - Neural network.
% 	    X       - Vector containing current values of weights and biases.
% 	    Pd      - Delayed input vectors.
% 	    Tl      - Layer target vectors.
% 	    Ai      - Initial input delay conditions.
% 	    Q       - Batch size.
% 	    TS      - Time steps.
% 	    dX      - Search direction vector.
% 	    gX      - Gradient vector.
% 	    PERF    - Performance value at current X.
% 	    DPERF   - Slope of performance value at current X in direction of dX.
% 	    DELTA   - Initial step size.
% 	    TOL     - Tolerance on search.
% 	    CH_PERF - Change in performance on previous step.
% 	  and returns,
% 	    A       - Step size which minimizes performance.
% 	    gX      - Gradient at new minimum point.
% 	    PERF    - Performance value at new minimum point.
% 	    RETCODE - Return code which has three elements. The first two elements correspond to
%                  the number of function evaluations in the two stages of the search
% 	              The third element is a return code. These will have different meanings
%                  for different search algorithms. Some may not be used in this function.
%                    0 - normal; 1 - minimum step taken; 2 - maximum step taken;
%                    3 - beta condition not met.
% 	    DELTA   - New initial step size. Based on the current step size.
% 	    TOL     - New tolerance on search.
% 
%      Parameters used for the brent algorithm are:
% 	    alpha     - Scale factor which determines sufficient reduction in perf.
% 	    beta      - Scale factor which determines sufficiently large step size.
% 	    bmax      - Largest step size.
% 	    scale_tol - Parameter which relates the tolerance tol to the initial step
%                    size delta. Usually set to 20.
%      The defaults for these parameters are set in the training function which
%      calls it.  See TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is an VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses SRCHBRE with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINCGF and
%      to use the line search function SRCHBRE:
% 	  1) Set NET.trainFcn to 'traincgf'.
% 	     This will set NET.trainParam to TRAINCGF's default parameters.
% 	  2) Set NET.trainParam.searchFcn to 'srchbre'.
% 
% 	  The SRCHBRE function can be used with any of the following
%      training functions: TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINCGF
%      network training function and the SRCHBRE search function are to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'traincgf');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
%        net.trainParam.searchFcn = 'srchbre';
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 
% 	Algorithm
% 
% 	  SRCHBRE brackets the minimum of the performance function in
% 	  the search direction dX, using Brent's
% 	  algorithm described on page 46 of Scales (Introduction to 
%      Non-Linear Estimation 1985). It is a hybrid algorithm based on 
%      the golden section search and quadratic approximation.
% 
% 	

function srchcha
%MATLAB Tour Partial Function Help:  nnt_con
%
% SRCHCHA One-dimensional minimization using the method of Charalambous.
% 
%  Syntax
%   
%   [a,gX,perf,retcode,delta,tol] = srchcha(net,X,Pd,Tl,Ai,Q,TS,dX,gX,
%                                                perf,dperf,delta,tol,ch_perf)
% 
%  Description
% 
%   SRCHCHA is a linear search routine.  It searches in a given direction
%     to locate the minimum of the performance function in that direction.
%     It uses a technique based on the method of Charalambous.
% 
%   SRCHCHA(NET,X,Pd,Tl,Ai,Q,TS,dX,gX,PERF,DPERF,DELTA,TOL,CH_PERF) 
%   takes these inputs,
%     NET     - Neural network.
%     X       - Vector containing current values of weights and biases.
%     Pd      - Delayed input vectors.
%     Tl      - Layer target vectors.
%     Ai      - Initial input delay conditions.
%     Q       - Batch size.
%     TS      - Time steps.
%     dX      - Search direction vector.
%     gX      - Gradient vector.
%     PERF    - Performance value at current X.
%     DPERF   - Slope of performance value at current X in direction of dX.
%     DELTA   - Initial step size.
%     TOL     - Tolerance on search.
%     CH_PERF - Change in performance on previous step.
%   and returns,
%     A       - Step size which minimizes performance.
%     gX      - Gradient at new minimum point.
%     PERF    - Performance value at new minimum point.
%     RETCODE - Return code which has three elements. The first two elements 
%               correspond to the number of function evaluations in the two 
%               stages of the search.  The third element is a return code. 
%               These will have different meanings for different search 
%               algorithms. Some may not be used in this function.
%                    0 - normal; 1 - minimum step taken; 2 - maximum step taken;
%                    3 - beta condition not met.
%     DELTA   - New initial step size. Based on the current step size.
%     TOL     - New tolerance on search.
% 
%   Parameters used for the Charalombous algorithm are:
%     alpha     - Scale factor which determines sufficient reduction in perf.
%     beta      - Scale factor which determines sufficiently large step size.
%     gama      - Parameter to avoid small reductions in performance. Usually
%                 set to 0.1.
%     scale_tol - Parameter which relates the tolerance tol to the initial step
%                 size delta. Usually set to 20.
%    The defaults for these parameters are set in the training function which
%    calls it.  See TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS
% 
%   Dimensions for these variables are:
%     Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
%     Tl - NlxTS cell array, each element P{i,ts} is an VixQ matrix.
%     Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
%     Where
%       Ni = net.numInputs
%     Nl = net.numLayers
%     LD = net.numLayerDelays
%     Ri = net.inputs{i}.size
%     Si = net.layers{i}.size
%     Vi = net.targets{i}.size
%     Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
%   Network Use
% 
%     You can create a standard network that uses SRCHCHA with
%     NEWFF, NEWCF, or NEWELM.
% 
%     To prepare a custom network to be trained with TRAINCGF using
%      the line search function SRCHCHA:
%     1) Set NET.trainFcn to 'traincgf'.
%        This will set NET.trainParam to TRAINCGF's default parameters.
%     2) Set NET.trainParam.searchFcn to 'srchcha'.
% 
%     The SRCHCHA function can be used with any of the following
%      training functions: TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS.
% 
% 
%   Examples
% 
%     Here is a problem consisting of inputs P and targets T that we would
%     like to solve with a network.
% 
%       P = [0 1 2 3 4 5];
%       T = [0 0 0 1 1 1];
% 
%     Here a two-layer feed-forward network is created.  The network's
%     input ranges from [0 to 10].  The first layer has two TANSIG
%     neurons, and the second layer has one LOGSIG neuron.  The TRAINCGF
%      network training function and the SRCHCHA search function are to be used.
% 
%       % Create and Test a Network
%       net = newff([0 5],[2 1],{'tansig','logsig'},'traincgf');
%       a = sim(net,p)
% 
%       % Train and Retest the Network
%        net.trainParam.searchFcn = 'srchcha';
%       net.trainParam.epochs = 50;
%       net.trainParam.show = 10;
%       net.trainParam.goal = 0.1;
%       net = train(net,p,t);
%       a = sim(net,p)
% 
% 
%   Algorithm
% 
%   SRCHCHA locates the minimum of the performance function in
%   the search direction dX, using an algorithm based on
%   the method described in Charalambous (IEE Proc. vol. 139, no. 3, June 1992).
% 
%   

function srchgol
%MATLAB Tour Partial Function Help:  nnt_con
%
% SRCHGOL One-dimensional minimization using golden section search.
% 
% 	Syntax
% 	
% 	  [a,gX,perf,retcode,delta,tol] = srchgol(net,X,Pd,Tl,Ai,Q,TS,dX,gX,perf,dperf,delta,tol,ch_perf)
% 
% 	Description
% 
% 	  SRCHGOL is a linear search routine.  It searches in a given direction
%      to locate the minimum of the performance function in that direction.
%      It uses a technique called the golden section search.
% 
% 	SRCHGOL(NET,X,Pd,Tl,Ai,Q,TS,dX,gX,PERF,DPERF,DELTA,TOL,CH_PERF) takes these inputs,
% 	    NET     - Neural network.
% 	    X       - Vector containing current values of weights and biases.
% 	    Pd      - Delayed input vectors.
% 	    Tl      - Layer target vectors.
% 	    Ai      - Initial input delay conditions.
% 	    Q       - Batch size.
% 	    TS      - Time steps.
% 	    dX      - Search direction vector.
% 	    gX      - Gradient vector.
% 	    PERF    - Performance value at current X.
% 	    DPERF   - Slope of performance value at current X in direction of dX.
% 	    DELTA   - Initial step size.
% 	    TOL     - Tolerance on search.
% 	    CH_PERF - Change in performance on previous step.
% 	  and returns,
% 	    A       - Step size which minimizes performance.
% 	    gX      - Gradient at new minimum point.
% 	    PERF    - Performance value at new minimum point.
% 	    RETCODE - Return code which has three elements. The first two elements correspond to
%                  the number of function evaluations in the two stages of the search
% 	              The third element is a return code. These will have different meanings
%                  for different search algorithms. Some may not be used in this function.
%                    0 - normal; 1 - minimum step taken; 2 - maximum step taken;
%                    3 - beta condition not met.
% 	    DELTA   - New initial step size. Based on the current step size.
% 	    TOL     - New tolerance on search.
% 
% 	Parameters used for the golden section algorithm are:
% 	  alpha     - Scale factor which determines sufficient reduction in perf.
% 	  bmax      - Largest step size.
% 	  scale_tol - Parameter which relates the tolerance tol to the initial step
%                  size delta. Usually set to 20.
%      The defaults for these parameters are set in the training function which
%      calls it.  See TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is an VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses SRCHGOL with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINCGF using the 
%      line search function SRCHGOL:
%      
% 	  1) Set NET.trainFcn to 'traincgf'.
% 	     This will set NET.trainParam to TRAINCGF's default parameters.
% 	  2) Set NET.trainParam.searchFcn to 'srchgol'.
% 
% 	  The SRCHGOL function can be used with any of the following
%      training functions: TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINCGF
%      network training function and the SRCHGOL search function are to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'traincgf');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
%        net.trainParam.searchFcn = 'srchgol';
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 
% 	Algorithm
% 
% 	  SRCHGOL locates the minimum of the performance function in
% 	  the search direction dX, using the
% 	  golden section search. It is based on the algorithm as
% 	  described on page 33 of Scales (Introduction to Non-Linear Estimation 1985).
% 
% 	

function srchhyb
%MATLAB Tour Partial Function Help:  nnt_con
%
% SRCHHYB One-dimensional minimization using a hybrid bisection-cubic search.
% 
% 	Syntax
% 	
% 	  [a,gX,perf,retcode,delta,tol] = srchhyb(net,X,P,T,Q,TS,dX,gX,perf,dperf,delta,tol,ch_perf)
% 
% 	Description
% 
% 	  SRCHHYB is a linear search routine.  It searches in a given direction
%      to locate the minimum of the performance function in that direction.
%      It uses a technique which is a combination of a bisection and a
%      cubic interpolation.
% 
% 	SRCHHYB(NET,X,Pd,Tl,Ai,Q,TS,dX,gX,PERF,DPERF,DELTA,TOL,CH_PERF) takes these inputs,
% 	    NET     - Neural network.
% 	    X       - Vector containing current values of weights and biases.
% 	    Pd      - Delayed input vectors.
% 	    Tl      - Layer target vectors.
% 	    Ai      - Initial input delay conditions.
% 	    Q       - Batch size.
% 	    TS      - Time steps.
% 	    dX      - Search direction vector.
% 	    gX      - Gradient vector.
% 	    PERF    - Performance value at current X.
% 	    DPERF   - Slope of performance value at current X in direction of dX.
% 	    DELTA   - Initial step size.
% 	    TOL     - Tolerance on search.
% 	    CH_PERF - Change in performance on previous step.
% 	  and returns,
% 	    A       - Step size which minimizes performance.
% 	    gX      - Gradient at new minimum point.
% 	    PERF    - Performance value at new minimum point.
% 	    RETCODE - Return code which has three elements. The first two elements correspond to
%                  the number of function evaluations in the two stages of the search
% 	              The third element is a return code. These will have different meanings
%                  for different search algorithms. Some may not be used in this function.
%                    0 - normal; 1 - minimum step taken; 2 - maximum step taken;
%                    3 - beta condition not met.
% 	    DELTA   - New initial step size. Based on the current step size.
% 	    TOL     - New tolerance on search.
% 
% 	  Parameters used for the hybrid bisection-cubic algorithm are:
% 	    alpha     - Scale factor which determines sufficient reduction in perf.
% 	    beta      - Scale factor which determines sufficiently large step size.
% 	    bmax      - Largest step size.
% 	    scale_tol - Parameter which relates the tolerance tol to the initial step
%                    size delta. Usually set to 20.
%      The defaults for these parameters are set in the training function which
%      calls it.  See TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is an VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses SRCHHYB with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINCGF using
%      the line search function SRCHHYB:
% 	  1) Set NET.trainFcn to 'traincgf'.
% 	     This will set NET.trainParam to TRAINCGF's default parameters.
% 	  2) Set NET.trainParam.searchFcn to 'srchhyb'.
% 
% 	  The SRCHHYB function can be used with any of the following
%      training functions: TRAINCGF, TRAINCGB, TRAINCGP, TRAINBFG, TRAINOSS.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINCGF
%      network training function and the SRCHHYB search function are to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'traincgf');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
%        net.trainParam.searchFcn = 'srchhyb';
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 
% 	Algorithm
% 
% 	  SRCHHYB locates the minimum of the performance function in
% 	  the search direction dX, using the hybrid
% 	  bisection-cubic interpolation algorithm described on page 50 of Scales.
% 	  (Introduction to Non-Linear Estimation 1985)
% 
% 	

function network
%MATLAB Tour Partial Function Help:  nnt_con
%
% NETWORK Create a custom neural network.
% 
% 	Synopsis
% 
% 	  net = network
% 	  net = network(numInputs,numLayers,biasConnect,inputConnect,
% 	    layerConnect,outputConnect,targetConnect)
% 
% 	Description
% 
% 	  NETWORK creates new custom networks.  It is used to create
% 	  networks that are then customized by functions such as NEWP,
% 	  NEWLIN, NEWFF, etc.
% 
% 	  NETWORK takes these optional arguments (shown with default values):
% 	    numInputs     - Number of inputs, 0.
% 	    numLayers     - Number of layers, 0.
% 	    biasConnect   - numLayers-by-1 Boolean vector, zeros.
% 	    inputConnect  - numLayers-by-numInputs Boolean matrix, zeros.
% 	    layerConnect  - numLayers-by-numLayers Boolean matrix, zeros.
% 	    outputConnect - 1-by-numLayers Boolean vector, zeros.
% 	    targetConnect - 1-by-numLayers Boolean vector, zeros.
% 	  and returns,
% 	    NET           - New network with the given property values.
% 
% 	Properties
% 
% 	  Architecture properties:
% 
% 	    net.numInputs: 0 or a positive integer.
% 	      Number of inputs.
% 	    net.numLayers: 0 or a positive integer.
% 	      Number of layers.
% 	    net.biasConnect: numLayer-by-1 Boolean vector.
% 	      If net.biasConnect(i) is 1 then the layer i has a bias and
% 	      net.biases{i} is a structure describing that bias.
% 	    net.inputConnect: numLayer-by-numInputs Boolean vector.
% 	      If net.inputConnect(i,j) is 1 then layer i has a weight coming from
% 	      input j and net.inputWeights{i,j} is a structure describing that weight.
% 	    net.layerConnect: numLayer-by-numLayers Boolean vector.
% 	      If net.layerConnect(i,j) is 1 then layer i has a weight coming from
% 	      layer j and net.layerWeights{i,j} is a structure describing that weight.
%        net.outputConnect: 1-by-numLayers Boolean vector.
% 	      If net.outputConnect(i) is 1 then the network has an output from
% 	      layer i and net.outputs{i} is a structure describing that output.
%        net.targetConnect: 1-by-numLayers Boolean vector.
% 	      if net.outputConnect(i) is 1 then the network has a target from
% 	      layer i and net.targets{i} is a structure describing that target.
% 	    net.numOutputs: 0 or a positive integer. Read only.
% 	      Number of network outputs according to net.outputConnect.
% 	    net.numTargets: 0 or a positive integer. Read only.
% 	      Number of targets according to net.targetConnect.
% 	    net.numInputDelays: 0 or a positive integer. Read only.
% 	      Maximum input delay according to all net.inputWeight{i,j}.delays.
% 	    net.numLayerDelays: 0 or a positive number. Read only.
% 	      Maximum layer delay according to all net.layerWeight{i,j}.delays.
% 
% 	Subobject structure properties:
% 
% 	    net.inputs: numInputs-by-1 cell array.
% 	      net.inputs{i} is a structure defining input i:
% 	    net.layers: numLayers-by-1 cell array.
% 	      net.layers{i} is a structure defining layer i:
%        net.biases: numLayers-by-1 cell array.
% 	      if net.biasConnect(i) is 1, then net.biases{i} is a structure
% 	      defining the bias for layer i.
% 	    net.inputWeights: numLayers-by-numInputs cell array.
% 	      if net.inputConnect(i,j) is 1, then net.inputWeights{i,j} is a
% 	      structure defining the weight to layer i from input j.
% 	    net.layerWeights: numLayers-by-numLayers cell array.
% 	      if net.layerConnect(i,j) is 1, then net.layerWeights{i,j} is a
% 	      structure defining the weight to layer i from layer j.
% 	    net.outputs: 1-by-numLayers cell array.
% 	      if net.outputConnect(i) is 1, then net.outputs{i} is a structure
% 	      defining the network output from layer i.
% 	    net.targets: 1-by-numLayers cell array.
% 	      if net.targetConnect(i) is 1, then net.targets{i} is a structure
% 	      defining the network target to layer i.
% 
% 	  Function properties:
% 
% 	    net.adaptFcn: name of a network adaption function or ''.
% 	    net.initFcn: name of a network initialization function or ''.
% 	    net.performFcn: name of a network performance function or ''.
% 	    net.trainFcn: name of a network training function or ''.
% 
% 	  Parameter properties:
% 
% 	    net.adaptParam: network adaption parameters.
% 	    net.initParam: network initialization parameters.
% 	    net.performParam: network performance parameters.
% 	    net.trainParam: network training parameters.
% 
% 	  Weight and bias value properties:
% 
% 	    net.IW: numLayers-by-numInputs cell array of input weight values.
% 	    net.LW: numLayers-by-numLayers cell array of layer weight values.
% 	    net.b: numLayers-by-1 cell array of bias values.
% 
% 	  Other properties:
% 
% 	    net.userdata: structure you can use to store useful values.
% 
% 	Examples
% 
% 	  Here is how the code to create a network without any inputs and layers,
% 	  and then set its number of inputs and layer to 1 and 2 respectively.
% 
% 	    net = network
% 	    net.numInputs = 1
% 	    net.numLayers = 2
% 
% 	  Here is the code to create the same network with one line of code.
% 
% 	    net = network(1,2)
% 
% 	  Here is the code to create a 1 input, 2 layer, feed-forward network.
% 	  Only the first layer will have a bias.  An input weight will
% 	  connect to layer 1 from input 1.  A layer weight will connect
% 	  to layer 2 from layer 1.  Layer 2 will be a network output,
% 	  and have a target.
% 
% 	    net = network(1,2,[1;0],[1; 0],[0 0; 1 0],[0 1],[0 1])
% 
% 	  We can then see the properties of subobjects as follows:
% 
% 	    net.inputs{1}
% 	    net.layers{1}, net.layers{2}
% 	    net.biases{1}
% 	    net.inputWeights{1,1}, net.layerWeights{2,1}
% 	    net.outputs{2}
% 	    net.targets{2}
% 
% 	  We can get the weight matrices and bias vector as follows:
% 
% 	    net.iw.{1,1}, net.iw{2,1}, net.b{1}
% 
% 	  We can alter the properties of any of these subobjects.  Here
% 	  we change the transfer functions of both layers:
% 
% 	    net.layers{1}.transferFcn = 'tansig';
% 	    net.layers{2}.transferFcn = 'logsig';
% 
% 	  Here we change the number of elements in input 1 to 2, by setting
%      each element's range:
% 
% 	    net.inputs{1}.range = [0 1; -1 1];
% 
% 	  Next we can simulate the network for a 2-element input vector:
% 
% 	    p = [0.5; -0.1];
% 	    y = sim(net,p)
% 
% 	

function newc
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWC Create a competitive layer.
% 
% 	Syntax
% 
% 	  net = newc(PR,S,KLR,CLR)
% 
% 	Description
% 
% 	  Competitive layers are used to solve classification
% 	  problems.
% 
% 	  NET = NEWC(PR,S,KLR,CLR) takes these inputs,
% 	    PR - Rx2 matrix of min and max values for R input elements.
% 	    S  - Number of neurons.
% 	    KLR - Kohonen learning rate, default = 0.01.
% 	    CLR - Conscience learning rate, default = 0.001.
% 	  Returns a new competitive layer.
% 
% 	Examples
% 
% 	  Here is a set of four two-element vectors P.
% 
% 	    P = [.1 .8  .1 .9; .2 .9 .1 .8];
% 
% 	  To competitive layer can be used to divide these inputs
% 	  into two classes.  First a two neuron layer is created
% 	  with two input elements ranging from 0 to 1, then it
% 	  is trained.
% 
% 	    net = newc([0 1; 0 1],2);
% 	    net = train(net,P);
% 
% 	  The resulting network can then be simulated and its
% 	  output vectors converted to class indices.
% 
% 	    Y = sim(net,P)
% 	    Yc = vec2ind(Y)
% 
% 	Properties
% 
% 	  Competitive layers consist of a single layer with the NEGDIST
% 	  weight function, NETSUM net input function, and the COMPET
% 	  transfer function.
% 
% 	  The layer has a weight from the input, and a bias.
% 
% 	  Weights and biases are initialized with MIDPOINT and INITCON.
% 
% 	  Adaption and training are done with ADAPTWB and TRAINWB1,
% 	  which both update weight and bias values with the LEARNK
% 	  and LEARNCON learning functions.
% 
% 	

function newcf
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWCF Create a cascade-forward backpropagation network.
% 
% 	Syntax
% 
% 	  net = newcf(Pr,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF)
% 
% 	Description
% 
% 	  NEWCF(PR,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF) takes,
% 	    PR  - Rx2 matrix of min and max values for R input elements.
% 	    Si  - Size of ith layer, for Nl layers.
% 	    TFi - Transfer function of ith layer, default = 'tansig'.
% 	    BTF - Backprop network training function, default = 'trainlm'.
% 	    BLF - Backprop weight/bias learning function, default = 'learngdm'.
% 	    PF  - Performance function, default = 'mse'.
% 	  and returns an N layer cascade-forward backprop network.
% 
% 	  The transfer functions TFi can be any differentiable transfer
% 	  function such as TANSIG, LOGSIG, or PURELIN.
% 
% 	  The training function BTF can be any of the backprop training
% 	  functions such as TRAINLM, TRAINBFG, TRAINRP, TRAINGD, etc.
% 
% 	  *WARNING*: TRAINLM is the default training function because it
% 	  is very fast, but it requires a lot of memory to run.  If you get
% 	  an "out-of-memory" error when training try doing one of these:
% 
% 	  (1) Slow TRAINLM training, but reduce memory requirements, by
% 	      setting NET.trainParam.mem_reduc to 2 or more. (See HELP TRAINLM.)
% 	  (2) Use TRAINBFG, which is slower but more memory efficient than TRAINLM.
% 	  (3) Use TRAINRP which is slower but more memory efficient than TRAINBFG.
% 
% 
% 	  The learning function BLF can be either of the backpropagation
% 	  learning functions such as LEARNGD, or LEARNGDM.
% 
% 	  The performance function can be any of the differentiable performance
% 	  functions such as MSE or MSEREG.
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5 6 7 8 9 10];
% 	    T = [0 1 2 3 4 3 2 1 2 3 4];
% 
% 	  Here a two-layer cascade-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has five TANSIG
% 	  neurons, the second layer has one PURELIN neuron.  The TRAINLM
% 	  network training function is to be used.
% 
% 	    net = newcf([0 10],[5 1],{'tansig' 'purelin'});
% 
% 	  Here the network is simulated and its output plotted against
% 	  the targets.
% 
% 	    Y = sim(net,P);
%        plot(P,T,P,Y,'o')
% 
% 	  Here the network is trained for 50 epochs.  Again the network's
%      output is plotted.
% 
% 	    net.trainParam.epochs = 50;
% 	    net = train(net,P,T);
% 	    Y = sim(net,P);
%        plot(P,T,P,Y,'o')
% 
% 	Algorithm
% 
% 	  Cascade-forward networks consists of Nl layers using the DOTPROD
% 	  weight function, NETSUM net input function, and the specified
% 	  transfer functions.
% 
% 	  The first layer has weights coming from the input.  Each subsequent
% 	  layer has weights coming from the input and all previous layers.
% 	  All layers have biases.  The last layer is the network output.
% 
% 	  Each layer's weights and biases are initialized with INITNW.
% 
% 	  Adaption is done with ADAPTWB which updates weights with the
% 	  specified learning function. Training is done with the specified
% 	  training function. Performance is measured according to the specified
% 	  performance function.
% 
% 	

function newelm
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWELM Create an Elman backpropagation network.
% 
% 	Syntax
% 
% 	  net = newelm(PR,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF)
% 
% 	Description
% 	  
%      NEWELM(PR,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF) takes several arguments,
% 	    PR  - Rx2 matrix of min and max values for R input elements.
% 	    Si  - Size of ith layer, for Nl layers.
% 	    TFi - Transfer function of ith layer, default = 'tansig'.
% 	    BTF - Backprop network training function, default = 'traingdx'.
% 	    BLF - Backprop weight/bias learning function, default = 'learngdm'.
% 	    PF  - Performance function, default = 'mse'.
% 	  and returns an Elman network.
% 
% 	  The training function BTF can be any of the backprop training
% 	  functions such as TRAINGD, TRAINGDM, TRAINGDA, TRAINGDX, etc.
% 
% 	  *WARNING*: Algorithms which take large step sizes, such as TRAINLM,
% 	  and TRAINRP, etc., are not recommended for Elman networks.  Because
% 	  of the delays in Elman networks the gradient of performance used
% 	  by these algorithms is only approximated making learning difficult
% 	  for large step algorithms.
% 
% 	  The learning function BLF can be either of the backpropagation
% 	  learning functions such as LEARNGD, or LEARNGDM.
% 
% 	  The performance function can be any of the differentiable performance
% 	  functions such as MSE or MSEREG.
% 
% 	Examples
% 
% 	  Here is a series of Boolean inputs P, and another sequence T
% 	  which is 1 wherever P has had two 1's in a row.
% 
% 	    P = round(rand(1,20));
% 	    T = [0 (P(1:end-1)+P(2:end) == 2)];
% 
% 	  We would like the network to recognize whenever two 1's
% 	  occur in a row.  First we arrange these values as sequences.
% 
% 	    Pseq = con2seq(P);
% 	    Tseq = con2seq(T);
% 
% 	  Next we create an Elman network whose input varies from 0 to 1,
% 	  and has five hidden neurons and 1 output.
% 
% 	    net = newelm([0 1],[10 1],{'tansig','logsig'});
% 
% 	  Then we train the network with a mean squared error goal of
% 	  0.1, and simulate it.
% 
% 	    net = train(net,Pseq,Tseq);
% 	    Y = sim(net,Pseq)
% 
% 	Algorithm
% 
% 	  Elman networks consists of Nl layers using the DOTPROD
% 	  weight function, NETSUM net input function, and the specified
% 	  transfer functions.
% 
% 	  The first layer has weights coming from the input.  Each subsequent
% 	  layer has a weight coming from the previous layer.  All layers except
% 	  the last have a recurrent weight. All layers have biases.  The last
% 	  layer is the network output.
% 
% 	  Each layer's weights and biases are initialized with INITNW.
% 
% 	  Adaption is done with ADAPTWB which updates weights with the
% 	  specified learning function. Training is done with the specified
% 	  training function. Performance is measured according to the specified
% 	  performance function.
% 
% 	

function newff
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWFF Create a feed-forward backpropagation network.
% 
% 	Syntax
% 
% 	  net = newff(PR,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF)
% 
% 	Description
% 
% 	  NEWFF(PR,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF) takes,
% 	    PR  - Rx2 matrix of min and max values for R input elements.
% 	    Si  - Size of ith layer, for Nl layers.
% 	    TFi - Transfer function of ith layer, default = 'tansig'.
% 	    BTF - Backprop network training function, default = 'trainlm'.
% 	    BLF - Backprop weight/bias learning function, default = 'learngdm'.
% 	    PF  - Performance function, default = 'mse'.
% 	  and returns an N layer feed-forward backprop network.
% 
% 	  The transfer functions TFi can be any differentiable transfer
% 	  function such as TANSIG, LOGSIG, or PURELIN.
% 
% 	  The training function BTF can be any of the backprop training
% 	  functions such as TRAINLM, TRAINBFG, TRAINRP, TRAINGD, etc.
% 
% 	  *WARNING*: TRAINLM is the default training function because it
% 	  is very fast, but it requires a lot of memory to run.  If you get
% 	  an "out-of-memory" error when training try doing one of these:
% 
% 	  (1) Slow TRAINLM training, but reduce memory requirements, by
% 	      setting NET.trainParam.mem_reduc to 2 or more. (See HELP TRAINLM.)
% 	  (2) Use TRAINBFG, which is slower but more memory efficient than TRAINLM.
% 	  (3) Use TRAINRP which is slower but more memory efficient than TRAINBFG.
% 
% 	  The learning function BLF can be either of the backpropagation
% 	  learning functions such as LEARNGD, or LEARNGDM.
% 
% 	  The performance function can be any of the differentiable performance
% 	  functions such as MSE or MSEREG.
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5 6 7 8 9 10];
% 	    T = [0 1 2 3 4 3 2 1 2 3 4];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has five TANSIG
% 	  neurons, the second layer has one PURELIN neuron.  The TRAINLM
% 	  network training function is to be used.
% 
% 	    net = newff([0 10],[5 1],{'tansig' 'purelin'});
% 
% 	  Here the network is simulated and its output plotted against
% 	  the targets.
% 
% 	    Y = sim(net,P);
%        plot(P,T,P,Y,'o')
% 
% 	  Here the network is trained for 50 epochs.  Again the network's
%      output is plotted.
% 
% 	    net.trainParam.epochs = 50;
% 	    net = train(net,P,T);
% 	    Y = sim(net,P);
%        plot(P,T,P,Y,'o')
% 
% 	Algorithm
% 
% 	  Feed-forward networks consist of Nl layers using the DOTPROD
% 	  weight function, NETSUM net input function, and the specified
% 	  transfer functions.
% 
% 	  The first layer has weights coming from the input.  Each subsequent
% 	  layer has a weight coming from the previous layer.  All layers
% 	  have biases.  The last layer is the network output.
% 
% 	  Each layer's weights and biases are initialized with INITNW.
% 
% 	  Adaption is done with ADAPTWB which updates weights with the
% 	  specified learning function. Training is done with the specified
% 	  training function. Performance is measured according to the specified
% 	  performance function.
% 
% 	

function newfftd
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWFFTD Create a feed-forward input-delay backprop network.
% 
% 	Syntax
% 
% 	  net = newfftd(PR,ID,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF)
% 
% 	Description
% 
% 	  NEWFFTD(PR,ID,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF) takes,
% 	    PR  - Rx2 matrix of min and max values for R input elements.
% 	    ID  - Input delay vector.
% 	    Si  - Size of ith layer, for Nl layers.
% 	    TFi - Transfer function of ith layer, default = 'tansig'.
% 	    BTF - Backprop network training function, default = 'trainlm'.
% 	    BLF - Backprop weight/bias learning function, default = 'learngdm'.
% 	    PF  - Performance function, default = 'mse'.
% 	  and returns an N layer feed-forward backprop network.
% 
% 	  The transfer functions TFi can be any differentiable transfer
% 	  function such as TANSIG, LOGSIG, or PURELIN.
% 
% 	  The training function BTF can be any of the backprop training
% 	  functions such as TRAINLM, TRAINBFG, TRAINRP, TRAINGD, etc.
% 
% 	  *WARNING*: TRAINLM is the default training function because it
% 	  is very fast, but it requires a lot of memory to run.  If you get
% 	  an "out-of-memory" error when training try doing one of these:
% 
% 	  (1) Slow TRAINLM training, but reduce memory requirements, by
% 	      setting NET.trainParam.mem_reduc to 2 or more. (See HELP TRAINLM.)
% 	  (2) Use TRAINBFG, which is slower but more memory efficient than TRAINLM.
% 	  (3) Use TRAINRP which is slower but more memory efficient than TRAINBFG.
% 
% 	  The learning function BLF can be either of the backpropagation
% 	  learning functions such as LEARNGD, or LEARNGDM.
% 
% 	  The performance function can be any of the differentiable performance
% 	  functions such as MSE or MSEREG.
% 
% 	Examples
% 
% 	  Here is a problem consisting of an input sequence P and target
% 	  sequence T that can be solved by a network with one delay.
% 
% 	    P = {1  0 0 1 1  0 1  0 0 0 0 1 1  0 0 1};
% 	    T = {1 -1 0 1 0 -1 1 -1 0 0 0 1 0 -1 0 1};
% 
% 	  Here a two-layer feed-forward network is created with input
% 	  delays of 0 and 1.  The network's input ranges from [0 to 1].
% 	  The first layer has five TANSIG neurons, the second layer has one
% 	  PURELIN neuron.  The TRAINLM network training function is to be used.
% 
% 	    net = newfftd([0 1],[0 1],[5 1],{'tansig' 'purelin'});
% 
% 	  Here the network is simulated.
% 
% 	    Y = sim(net,P)
% 
% 	  Here the network is trained for 50 epochs.  Again the network's
%      output is calculated.
% 
% 	    net.trainParam.epochs = 50;
% 	    net = train(net,P,T);
% 	    Y = sim(net,P)
% 
% 	Algorithm
% 
% 	  Feed-forward networks consists of Nl layers using the DOTPROD
% 	  weight function, NETSUM net input function, and the specified
% 	  transfer functions.
% 
% 	  The first layer has weights coming from the input with the
% 	  specified input delays.  Each subsequent layer has a weight coming
% 	  from the previous layer.  All layers have biases.  The last layer
% 	  is the network output.
% 
% 	  Each layer's weights and biases are initialized with INITNW.
% 
% 	  Adaption is done with ADAPTWB which updates weights with the
% 	  specified learning function. Training is done with the specified
% 	  training function. Performance is measured according to the specified
% 	  performance function.
% 
% 	

function newgrnn
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWGRNN Design a generalized regression neural network.
% 
% 	Synopsis
% 
% 	  net = newgrnn(P,T,SPREAD)
% 
% 	Description
% 
% 	  Generalized regression neural networks are a kind
% 	  of radial basis network that is often used for function
% 	  approximation.  GRNNs can be designed very quickly.
% 
% 	  NEWGRNN(P,T,SPREAD) takes these inputs,
% 	    P      - RxQ matrix of Q input vectors.
% 	    T      - SxQ matrix of Q target class vectors.
% 	    SPREAD - Spread of radial basis functions, default = 1.0.
% 	  and returns a new generalized regression neural network.
% 
% 	  The larger SPREAD is, the smoother the function approximation
% 	  will be.  To fit data closely, use a SPREAD smaller than the
% 	  typical distance between input vectors.  To fit the data more
% 	  smoothly use a larger SPREAD.
% 
% 	Examples
% 
% 	  Here we design a radial basis network given inputs P
% 	  and targets T.
% 
% 	    P = [1 2 3];
% 	    T = [2.0 4.1 5.9];
% 	    net = newgrnn(P,T);
% 
% 	  Here the network is simulated for a new input.
% 
% 	    P = 1.5;
% 	    Y = sim(net,P)
% 
% 	Properties
% 
% 	  NEWGRNN creates a two layer network. The first layer has
% 	  has RADBAS neurons, calculates weighted inputs with DIST and
% 	  net input with NETPROD.  The second layer has PURELIN neurons,
% 	  calculates weighted input with NORMPROD and net inputs with NETSUM.
% 	  Only the first layer has biases.
% 
% 	  NEWGRNN sets the first layer weights to P', and the first
% 	  layer biases are all set to 0.8326/SPREAD, resulting in
% 	  radial basis functions that cross 0.5 at weighted inputs
% 	  of +/- SPREAD. The second layer weights W2 are set to T.
% 
% 	References:
% 
% 	  P.D. Wasserman, Advanced Methods in Neural Computing, New York:
% 	    Van Nostrand Reinhold, pp. 155-61, 1993.
% 
% 	

function newhop
%MATLAB Tour Partial Function Help:  nnt_con
%
%  NEWHOP Create a Hopfield recurrent network.
% 
% 	Syntax
% 
% 	  net = newhop(T)
% 
% 	Description
% 
% 	  Hopfield networks are used for pattern recall.
% 
% 	  NEWHOP(T) takes one input argument,
% 	    T - RxQ matrix of Q target vectors. (Values must be +1 or -1.)
% 	  and returns a new Hopfield recurrent neural network with
% 	  stable points at the vectors in T.
% 
% 	Examples
% 
% 	  Here we create a Hopfield network with two three-element
% 	  stable points T.
% 
% 	    T = [-1 -1 1; 1 -1 1]';
% 	    net = newhop(T);
% 
% 	  Below we check that the network is stable at these points by
% 	  using them as initial layer delay conditions.  If the network is
% 	  stable we would expect that the outputs Y will be the same.
% 	  (Since Hopfield networks have no inputs, the second argument
% 	  to SIM is Q = 2 when using matrix notation).
% 
% 	    Ai = T;
% 	    [Y,Pf,Af] = sim(net,2,[],Ai);
% 	    Y
% 
% 	  To see if the network can correct a corrupted vector, run
% 	  the following code which simulates the Hopfield network for
% 	  five timesteps.  (Since Hopfield networks have no inputs,
% 	  the second argument to SIM is {Q TS} = [1 5] when using cell
% 	  array notation.)
% 
% 	    Ai = {[-0.9; -0.8; 0.7]};
% 	    [Y,Pf,Af] = sim(net,{1 5},{},Ai);
% 	    Y{1}
% 
% 	  If you run the above code Y{1} will equal T(:,1) if the
% 	  network has managed to convert the corrupted vector Ai to
% 	  the nearest target vector.
% 
% 	Algorithm
% 
% 	  Hopfield networks are designed to have stable layer outputs
% 	  as defined by user supplied targets.  The algorithm
% 	  minimizes the number of unwanted stable points.
% 
% 	Properties
% 
% 	  Hopfield networks consist of a single layer with the DOTPROD
% 	  weight function, NETSUM net input function, and the SATLINS
% 	  transfer function.
% 
% 	  The layer has a recurrent weight from itself and a bias.
% 
% 	Reference
% 
% 	  J. Li, A. N. Michel, W. Porod, "Analysis and synthesis of a
% 	  class of neural networks: linear systems operating on a
% 	  closed hypercube," IEEE Transactions on Circuits and Systems,
% 	  vol. 36, no. 11, pp. 1405-1422, November 1989.
% 
% 	

function newlin
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWLIN Create a linear layer.
% 
% 	Syntax
% 
% 	  net = newlin(PR,S,ID,LR)
% 	  new = newlin
% 
% 	Description
% 
% 	  Linear layers are often used as adaptive filters
% 	  for signal processing and prediction.
% 
% 	  NEWLIN(PR,S,ID,LR) takes these arguments,
% 	    PR - Rx2 matrix of min and max values for R input elements.
% 	    S  - Number of elements in the output vector.
% 	    ID - Input delay vector, default = [0].
% 	    LR - Learning rate, default = 0.01;
% 	  and returns a new linear layer.
% 
% 	  NET = NEWLIN(PR,S,0,P) takes an alternate argument,
% 	    P  - Matrix of input vectors.
% 	  and returns a linear layer with the maximum stable
% 	  learning rate for learning with inputs P.
% 
% 	Examples
% 
% 	  This code creates a single input (range of [-1 1] linear
% 	  layer with one neuron, input delays of 0 and 1, and a learning
% 	  rate of 0.01.  It is simulated for an input sequence P1.
% 
% 	    net = newlin([-1 1],1,[0 1],0.01);
% 	    P1 = {0 -1 1 1 0 -1 1 0 0 1};
% 	    Y = sim(net,P1)
% 
% 	  Here targets T1 are defined and the layer adapts to them.
% 	  (Since this is the first call to ADAPT, the default input
% 	  delay conditions are used.)
% 
% 	    T1 = {0 -1 0 2 1 -1 0 1 0 1};
% 	    [net,Y,E,Pf] = adapt(net,P1,T1); Y
% 
% 	  Here the linear layer continues to adapt for a new sequence
% 	  using the previous final conditions PF as initial conditions.
% 
% 	    P2 = {1 0 -1 -1 1 1 1 0 -1};
% 	    T2 = {2 1 -1 -2 0 2 2 1 0};
% 	    [net,Y,E,Pf] = adapt(net,P2,T2); Y
% 
% 	  Here we initialize the layer's weights and biases to new values.
% 
% 	    net = init(net);
% 
% 	  Here we train the newly initialized layer on the entire sequence
% 	  for 200 epochs to an error goal of 0.1.
% 
% 	    P3 = [P1 P2];
% 	    T3 = [T1 T2];
% 	    net.trainParam.epochs = 200;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,P3,T3);
% 	    Y = sim(net,[P1 P2])
% 
% 	Algorithm
% 
% 	  Linear layers consist of a single layer with the DOTPROD
% 	  weight function, NETSUM net input function, and PURELIN
% 	  transfer function.
% 
% 	  The layer has a weight from the input and a bias.
% 
% 	  Weights and biases are initialized with INITZERO.
% 
% 	  Adaption and training are done with ADAPTWB and TRAINWB,
% 	  which both update weight and bias values with LEARNWH.
% 	  Performance is measured with MSE.
% 
% 	

function newlind
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWLIND Design a linear layer.
% 
% 	Syntax
% 
% 	  net = newlind(P,T)
% 
% 	Description
% 
% 	  NEWLIND(P,T) takes two input arguments,
% 	    P - RxQ matrix of Q input vectors.
% 	    T - SxQ matrix of Q target class vectors.
% 	  and returns a linear layer designed to output T
% 	  (with minimum sum square error) given input P.
% 
% 	Examples
% 
% 	  We would like a linear layer that outputs T given P
% 	  for the following definitions.
% 
% 	    P = [1 2 3];
% 	    T = [2.0 4.1 5.9];
% 
% 	  Here we use NETLIND to design such a network and
% 	  check its response.
% 
% 	    net = newlind(P,T);
% 	    Y = sim(net,P)
% 
% 	Algorithm
% 
% 	  NEWLIND calculates weight W and bias B values for a
%      linear layer from inputs P and targets T by solving
% 	  this linear equation in the least squares sense:
% 	  
% 	    [W b] * [P; ones] = T
% 
% 	

function newlvq
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWLVQ Create a learning vector quantization network.
% 
% 	Syntax
% 
% 	  net = newlvq(PR,S1,PC,LR,LF)
% 
% 	Description
% 
% 	  LVQ networks are used to solve classification
% 	  problems.
% 
% 	  NET = NEWLVQ(PR,S1,PC,LR,LF) takes these inputs,
% 	    PR - Rx2 matrix of min and max values for R input elements.
% 	    S1 - Number of hidden neurons.
% 	    PC - S2 element vector of typical class percentages.
% 	    LR - Learning rate, default = 0.01.
% 	    LF - Learning function, default = 'learnlv2'.
% 	  Returns a new LVQ network.
% 
%      The learning function LF can be LEARNLV1 or LEARNLV2.
% 
% 	Examples
% 
% 	  The input vectors P and target classes Tc below define
% 	  a classification problem to be solved by an LVQ network.
% 
% 	    P = [-3 -2 -2  0  0  0  0 +2 +2 +3; ...
% 	         0 +1 -1 +2 +1 -1 -2 +1 -1  0];
% 	    Tc = [1 1 1 2 2 2 2 1 1 1];
% 
% 	  Target classes Tc are converted to target vectors T. Then an
% 	  LVQ network is created (with inputs ranges obtained from P,
% 	  4 hidden neurons, and class percentages of 0.6 and 0.4)
% 	  and is trained.
% 
% 	    T = ind2vec(Tc);
% 	    net = newlvq(minmax(P),4,[.6 .4]);
% 	    net = train(net,P,T);
% 
% 	  The resulting network can be tested.
% 
% 	    Y = sim(net,P)
% 	    Yc = vec2ind(Y)
% 
% 	Properties
% 
% 	  NEWLVQ creates a two layer network. The first layer uses the
% 	  COMPET transfer function, calculates weighted inputs with NEGDIST, and
% 	  net input with NETSUM.  The second layer has PURELIN neurons,
% 	  calculates weighted input with DOTPROD and net inputs with NETSUM.
% 	  Neither layer has biases.
% 
% 	  First layer weights are initialized with MIDPOINT.  The
% 	  second layer weights are set so that each output neuron i
% 	  has unit weights coming to it from PC(i) percent of the
% 	  hidden neurons.
% 
% 	  Adaption and training are done with ADAPTWB and TRAINWB1,
% 	  which both update the first layer weights with the specified
% 	  learning functions.
% 
% 	

function newp
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWP Create a perceptron.
% 
% 	Syntax
% 
% 	  net = newp(pr,s,tf,lf)
% 
% 	Description
% 
% 	  Perceptrons are used to solve simple (i.e. linearly
% 	  separable) classification problems.
% 
% 	  NET = NEWP(PR,S,TF,LF) takes these inputs,
% 	    PR - Rx2 matrix of min and max values for R input elements.
% 	    S  - Number of neurons.
% 	    TF - Transfer function, default = 'hardlim'.
% 	    LF - Learning function, default = 'learnp'.
% 	  Returns a new perceptron.
% 
% 	  The transfer function TF can be HARDLIM or HARDLIMS.
% 	  The learning function LF can be LEARNP or LEARNPN.
% 
% 	  Call NEWP without input arguments to define the network's
% 	  attributes in a dialog window.
% 
% 	Examples
% 
% 	  This code creates a perceptron layer with one 2-element
% 	  input (ranges [0 1] and [-2 2]) and one neuron. (Supplying
% 	  only two arguments to NEWP results in the default perceptron
% 	  learning function LEARNP being used.)
% 
% 	    net = newp([0 1; -2 2],1);
% 
% 	  Here we simulate the network to a sequence of inputs P.
% 
% 	    P1 = {[0; 0] [0; 1] [1; 0] [1; 1]};
% 	    Y = sim(net,P1)
% 
% 	  Here we define a sequence of targets T (together P and T
% 	  define the operation of an AND gate), and then let the
% 	  network adapt for 10 passes through the sequence.  We
% 	  then simulate the updated network.
% 
% 	    T1 = {0 0 0 1};
% 	    net.adaptParam.passes = 10;
% 	    net = adapt(net,P1,T1);
% 	    Y = sim(net,P1)
% 
% 	  Now we define a new problem, an OR gate, with batch inputs P
% 	  and targets T.
% 
% 	    P2 = [0 0 1 1; 0 1 0 1];
% 	    T2 = [0 1 1 1];
% 
% 	  Here we initialize the perceptron (resulting in new random
% 	  weight and bias values), simulate its output, train for a
% 	  maximum of 20 epochs, and then simulate it again.
% 
% 	    net = init(net);
% 	    Y = sim(net,P2)
% 	    net.trainParam.epochs = 20;
% 	    net = train(net,P2,T2);
% 	    Y = sim(net,P2)
% 
% 	Notes
% 
% 	  Perceptrons can classify linearly separable classes in a
% 	  finite amount of time. If input vectors have a large variance
% 	  in their lengths, the LEARNPN can be faster than LEARNP.
% 
% 	Properties
% 
% 	  Perceptrons consist of a single layer with the DOTPROD
% 	  weight function, the NETSUM net input function, and the specified
% 	  transfer function.
% 
% 	  The layer has a weight from the input and a bias.
% 
% 	  Weights and biases are initialized with INITZERO.
% 
% 	  Adaption and training are done with ADAPTWB and TRAINWB,
% 	  which both update weight and bias values with the specified
% 	  learning function.  Performance is measured with MAE.
% 
% 	

function newpnn
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWPNN Design a probabilistic neural network.
% 
% 	Synopsis
% 
% 	  net = newpnn(P,T,SPREAD)
% 
% 	Description
% 
% 	  Probabilistic neural networks are a kind of radial
% 	  basis network suitable for classification problems.
% 
% 	  NET = NEWPNN(P,T,SPREAD) takes two or three arguments,
% 	    P      - RxQ matrix of Q input vectors.
% 	    T      - SxQ matrix of Q target class vectors.
% 	    SPREAD - Spread of radial basis functions, default = 0.1.
% 	  and returns a new probabilistic neural network.
% 
% 	  If SPREAD is near zero the network will act as a nearest
% 	  neighbor classifier.  As SPREAD becomes larger the designed
% 	  network will take into account several nearby design vectors.
% 
% 	Examples
% 
% 	  Here a classification problem is defined with a set of
% 	  inputs P and class indices Tc.
% 
% 	    P = [1 2 3 4 5 6 7];
% 	    Tc = [1 2 3 2 2 3 1];
% 
% 	  Here the class indices are converted to target vectors,
% 	  and a PNN is designed and tested.
% 
% 	    T = ind2vec(Tc)
% 	    net = newpnn(P,T);
% 	    Y = sim(net,P)
% 	    Yc = vec2ind(Y)
% 
% 	Algorithm
% 
% 	  NEWPNN creates a two layer network. The first layer has RADBAS
% 	  RADBAS neurons, and calculates its weighted inputs with DIST, and
% 	  its net input with NETPROD.  The second layer has COMPET neurons,
% 	  and calculates its weighted input with DOTPROD and its net inputs
% 	  with NETSUM. Only the first layer has biases.
% 
% 	  NEWPNN sets the first layer weights to P', and the first
% 	  layer biases are all set to 0.8326/SPREAD resulting in
% 	  radial basis functions that cross 0.5 at weighted inputs
% 	  of +/- SPREAD. The second layer weights W2 are set to T.
% 
% 	References
% 
% 	  P.D. Wasserman, Advanced Methods in Neural Computing, New York:
%        Van Nostrand Reinhold, pp. 35-55, 1993.
% 
% 	

function newrb
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWRB Design a radial basis network.
% 
% 	Synopsis
% 
% 	  net = newrb(P,T,GOAL,SPREAD)
% 
% 	Description
% 
% 	  Radial basis networks can be used to approximate
% 	  functions.  NEWRB adds neurons to the hidden
% 	  layer of a radial basis network until it meets
% 	  the specified mean squared error goal.
% 
% 	  NEWRB(PR,T,GOAL,SPREAD) takes two to four arguments,
% 	    P      - RxQ matrix of Q input vectors.
% 	    T      - SxQ matrix of Q target class vectors.
% 	    GOAL   - Mean squared error goal, default = 0.0.
% 	    SPREAD - Spread of radial basis functions, default = 1.0.
% 	  and returns a new radial basis network.
% 
% 	  The larger that SPREAD is the smoother the function approximation
% 	  will be.  Too large a spread means a lot of neurons will be
% 	  required to fit a fast changing function.  Too small a spread
% 	  means many neurons will be required to fit a smooth function,
% 	  and the network may not generalize well.  Call NEWRB with
% 	  different spreads to find the best value for a given problem.
% 
% 	Examples
% 
% 	  Here we design a radial basis network given inputs P
% 	  and targets T.
% 
% 	    P = [1 2 3];
% 	    T = [2.0 4.1 5.9];
% 	    net = newrb(P,T);
% 
% 	  Here the network is simulated for a new input.
% 
% 	    P = 1.5;
% 	    Y = sim(net,P)
% 
% 	Algorithm
% 
% 	  NEWRB creates a two layer network. The first layer has RADBAS
% 	  neurons, and calculates its weighted inputs with DIST, and
% 	  its net input with NETPROD.  The second layer has PURELIN neurons,
% 	  calculates its weighted input with DOTPROD and its net inputs with
% 	  NETSUM. Both layers have biases.
% 
% 	  Initially the RADBAS layer has no neurons.  The following steps
% 	  are repeated until the network's mean squared error falls below GOAL.
% 	  1) The network is simulated
% 	  2) The input vector with the greatest error is found
% 	  3) A RADBAS neuron is added with weights equal to that vector.
% 	  4) The PURELIN layer weights are redesigned to minimize error.
% 
% 	

function newrbe
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWRBE Design an exact radial basis network.
% 
% 	Synopsis
% 
% 	  net = newrbe(P,T,SPREAD)
% 
% 	Description
% 
% 	  Radial basis networks can be used to approximate functions.
% 	  NEWRBE very quickly designs a radial basis network with
% 	  zero error on the design vectors.
% 
% 	  NEWRBE(P,T,SPREAD) takes two or three arguments,
% 	  P      - RxQ matrix of Q input vectors.
% 	  T      - SxQ matrix of Q target class vectors.
% 	  SPREAD - of radial basis functions, default = 1.0.
% 	  and returns a new exact radial basis network.
% 
% 	  The larger that SPREAD, is the smoother the function approximation
% 	  will be. Too large a spread can cause numerical problems.
% 
% 	Examples
% 
% 	  Here we design a radial basis network, given inputs P
% 	  and targets T.
% 
% 	    P = [1 2 3];
% 	    T = [2.0 4.1 5.9];
% 	    net = newrbe(P,T);
% 
% 	  Here the network is simulated for a new input.
% 
% 	    P = 1.5;
% 	    Y = sim(net,P)
% 
% 	Algorithm
% 
% 	  NEWRBE creates a two layer network. The first layer has RADBAS
% 	  neurons, and calculates its weighted inputs with DIST, and its
% 	  net input with NETPROD.  The second layer has PURELIN neurons,
% 	  and calculates its weighted input with DOTPROD and its net inputs
% 	  with NETSUM. Both layer's have biases.
% 
% 	  NEWRBE sets the first layer weights to P', and the first
% 	  layer biases are all set to 0.8326/SPREAD, resulting in
% 	  radial basis functions that cross 0.5 at weighted inputs
% 	  of +/- SPREAD.
% 
% 	  The second layer weights IW{2,1} and biases b{2} are found by
% 	  simulating the first layer outputs A{1}, and then solving the
% 	  following linear expression:
% 
% 	      [W{2,1} b{2}] * [A{1}; ones] = T
% 
% 	

function newsom
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEWSOM Create a self-organizing map.
% 
% 	Syntax
% 
% 	  net = newsom(PR,[d1,d2,...],tfcn,dfcn,olr,osteps,tlr,tns)
% 
% 	Description
% 
% 	  Competitive layers are used to solve classification
% 	  problems.
% 
% 	  NET = NEWSOM(PR,[D1,D2,...],TFCN,DFCN,OLR,OSTEPS,TLR,TNS) takes,
% 	    PR     - Rx2 matrix of min and max values for R input elements.
% 	    Di     - Size of ith layer dimension, defaults = [5 8].
% 	    TFCN   - Topology function, default = 'hextop'.
% 	    DFCN   - Distance function, default = 'linkdist'.
% 	    OLR    - Ordering phase learning rate, default = 0.9.
% 	    OSTEPS - Ordering phase steps, default = 1000.
% 	    TLR    - Tuning phase learning rate, default = 0.02;
% 	    TND    - Tuning phase neighborhood distance, default = 1.
% 	  and returns a new self-organizing map.
% 
% 	  The topology function TFCN can be HEXTOP, GRIDTOP, or RANDTOP.
% 	  The distance function can be LINKDIST, DIST, or MANDIST.
% 
% 	Examples
% 
% 	  The input vectors defined below are distributed over
% 	  an 2-dimension input space varying over [0 2] and [0 1].
% 	  This data will be used to train a SOM with dimensions [3 5].
% 
% 	    P = [rand(1,400)*2; rand(1,400)];
% 	    net = newsom([0 2; 0 1],[3 5]);
% 	    plotsom(net.layers{1}.positions)
% 
% 	  Here the SOM is trained and the input vectors are plotted with
% 	  the map which the SOM's weights has formed.
% 
% 	    net = train(net,P);
% 	    plot(P(1,:),P(2,:),'.g','markersize',20)
% 	    hold on
% 	    plotsom(net.iw{1,1},net.layers{1}.distances)
% 	    hold off
% 
% 	Properties
% 
% 	  SOMs consist of a single layer with the NEGDIST weight function,
% 	  NETSUM net input function, and the COMPET transfer function.
% 
% 	  The layer has a weight from the input, but no bias.
% 	  The weight is initialized with MIDPOINT.
% 
% 	  Adaption and training are done with ADAPTWB and TRAINWB1,
% 	  which both update the weight with LEARNSOM.
% 
% 	

function netprod
%MATLAB Tour Partial Function Help:  nnt_con
%
% NETPROD Product net input function.
% 
% 	Syntax
% 
% 	  N = netprod(Z1,Z2,...)
% 	  df = netprod('deriv')
% 
% 	Description
% 
% 	  NETPROD is a net input function.  Net input functions
% 	  calculate a layer's net input by combining its weighted
% 	  inputs and biases.
% 
% 	  NETPROD(Z1,Z2,...,Zn)
% 	    Zi - SxQ matrices.
% 	  Returns element-wise sum of Zi's.
% 
% 	  NETPROD('deriv') returns NETPROD's derivative function.
% 
% 	Examples
% 
% 	  Here NETPROD combines two sets of weighted input
% 	  vectors (which we have defined ourselves).
% 
% 	    z1 = [1 2 4;3 4 1];
% 	    z2 = [-1 2 2; -5 -6 1];
% 	    n = netprod(z1,z2)
% 
% 	  Here NETPROD combines the same weighted inputs with
% 	  a bias vector.  Because Z1 and Z2 each contain three
% 	  concurrent vectors, three concurrent copies of B must
% 	  be created with CONCUR so that all sizes match up.
% 
% 	    b = [0; -1];
% 	    n = netprod(z1,z2,concur(b,3))
% 
% 	Network Use
% 
% 	  You can create a standard network that uses NETPROD
% 	  by calling NEWPNN or NEWGRNN.
% 
% 	  To change a network so that a layer uses NETPROD, set
% 	  NET.layers{i}.netInputFcn to 'netprod'.
% 
% 	  In either case, call SIM to simulate the network with NETPROD.
% 	  See NEWPNN or NEWGRNN for simulation examples.
% 
% 	

function netsum
%MATLAB Tour Partial Function Help:  nnt_con
%
% NETSUM Sum net input function.
% 
% 	Syntax
% 
% 	  N = netsum(Z1,Z2,...)
% 	  df = netsum('deriv')
% 
% 	Description
% 
% 	  NETSUM is a net input function.  Net input functions
% 	  calculate a layer's net input by combining its weighted
% 	  inputs and biases.
% 
% 	  NETSUM(Z1,Z2,...,Zn) takes any number of inputs,
% 	    Zi - SxQ matrices.
% 	  and the returns N the element-wise sum of Zi's.
% 
% 	  NETSUM('deriv') returns NETSUM's derivative function.
% 
% 	Examples
% 
% 	  Here NETSUM combines two sets of weighted input
% 	  vectors (which we have defined ourselves).
% 
% 	    z1 = [1 2 4;3 4 1];
% 	    z2 = [-1 2 2; -5 -6 1];
% 	    n = netsum(z1,z2)
% 
% 	  Here NETSUM combines the same weighted inputs with
% 	  a bias vector.  Because Z1 and Z2 each contain three
% 	  concurrent vectors, three concurrent copies of B must
% 	  be created with CONCUR so that all sizes match up.
% 
% 	    b = [0; -1];
% 	    n = netsum(z1,z2,concur(b,3))
% 
% 	Network Use
% 
% 	  You can create a standard network that uses NETSUM
% 	  by calling NEWP or NEWLIN.
% 
% 	  To change a network so a layer uses NETSUM, set
% 	  NET.layers{i}.netInputFcn to 'netsum'.
% 
% 	  In either case, call SIM to simulate the network with NETSUM.
% 	  See NEWP or NEWLIN for simulation examples.
% 
% 	

function dnetprod
%MATLAB Tour Partial Function Help:  nnt_con
%
% DNETPROD Derivative of net input product function.
% 
% 	Syntax
% 
% 	  dN_dZ = dnetprod(Z,N)
% 
% 	Description
% 
% 	  DNETPROD is the net input derivative function for NETPROD.
% 
% 	  DNETPROD takes two arguments,
% 	    Z - SxQ weighted input.
% 	    N - SxQ net input.
% 	  and returns the SxQ derivative dN/dZ.
% 
% 	Examples
% 
% 	  Here we define two weighted inputs for a layer with
% 	  three neurons.
% 
% 	    Z1 = [0; 1; -1];
% 	    Z2 = [1; 0.5; 1.2];
% 
% 	  We calculate the layer's net input N with NETPROD and then
% 	  the derivative of N with respect to each weighted input.
% 
% 	    N = netprod(Z1,Z2)
% 	    dN_dZ1 = dnetprod(Z1,N)
% 	    dN_dZ2 = dnetprod(Z2,N)
% 
% 	Algorithm
% 
% 	  The derivative a product with respect to any element of that
% 	  product is the product of the other elements.
% 
% 	

function dnetsum
%MATLAB Tour Partial Function Help:  nnt_con
%
% DNETSUM Sum net input derivative function.
% 
% 	Syntax
% 
% 	  dN_dZ = dnetsum(Z,N)
% 
% 	Description
% 
% 	  DNETSUM is the net input derivative function for NETSUM.
% 
% 	  DNETSUM takes two arguments,
% 	    Z - SxQ weighted input.
% 	    N - SxQ net input.
% 	  and returns the SxQ derivative dN/dZ.
% 
% 	Examples
% 
% 	  Here we define two weighted inputs for a layer with
% 	  three neurons.
% 
% 	    Z1 = [0; 1; -1];
% 	    Z2 = [1; 0.5; 1.2];
% 
% 	  We calculate the layer's net input N with NETSUM and then
% 	  the derivative of N with respect to each weighted input.
% 
% 	    N = netsum(Z1,Z2)
% 	    dN_dZ1 = dnetsum(Z1,N)
% 	    dN_dZ2 = dnetsum(Z2,N)
% 
% 	Algorithm
% 
% 	  The derivative of a sum with respect to any element of that
% 	  sum is always a ones matrix that is the same size as the sum.
% 
% 	

function initlay
%MATLAB Tour Partial Function Help:  nnt_con
%
% INITLAY Layer-by-layer network initialization function.
% 
% 	Syntax
% 
% 	  net = initlay(net)
% 	  info = initlay(code)
% 
% 	Description
% 
% 	  INITLAY is a network initialization function which
% 	  initializes each layer i according to its own initialization
% 	  function NET.layers{i}.initFcn.
% 
% 	  INITLAY(NET) takes:
% 	    NET - Neural network.
% 	  and returns the network with each layer updated.
% 
% 	  INITLAY(CODE) return useful information for each CODE string:
% 	    'pnames'    - Names of initialization parameters.
% 	    'pdefaults' - Default initialization parameters.
% 
% 	  INITLAY does not have any initialization parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses INITLAY by calling
% 	  NEWP, NEWLIN, NEWFF, NEWCF, and many other new network functions.
% 
% 	  To prepare a custom network to be initialized with INITLAY:
% 	  1) Set NET.initFcn to 'initlay'.
% 	     (This will set NET.initParam to the empty matrix [] since
% 	     INITLAY has no initialization parameters.)
% 	  2) Set each NET.layers{i}.initFcn to a layer initialization function.
% 	     (Examples of such functions are INITWB and INITNW).
% 
% 	  To initialize the network call INIT.
% 
% 	  See NEWP and NEWLIN for initialization examples.
% 
% 	Algorithm
% 
% 	  The weights and biases of each layer i are initialized according
% 	  to NET.layers{i}.initFcn.
% 
% 	

function mae
%MATLAB Tour Partial Function Help:  nnt_con
%
% MAE Mean absolute error performance function.
% 
% 	Syntax
% 
% 	  perf = mae(e,x,pp)
% 	  perf = mae(e,net,pp)
% 	  info = mae(code)
% 
% 	Description
% 
% 	  MAE is a network performance function.
% 	
% 	  MAE(E,X,PP) takes from one to three arguments,
% 	    E - Matrix or cell array of error vector(s).
% 	    X  - Vector of all weight and bias values (ignored).
% 	    PP - Performance parameters (ignored).
%      and returns the mean absolute error.
% 
% 	  The errors E can be given in cell array form,
% 	    E - NtxTS cell array, each element E{i,ts} is a VixQ matrix or [].
% 	  or as a matrix,
% 	    E - (sum of Vi)xQ matrix
% 	  where:
% 	    Nt = net.numTargets
% 	    TS = number of time steps
% 	    Q  = batch size
% 	    Vi = net.targets{i}.size
% 
% 	  MAE(E,NET,PP) can take an alternate argument to X,
% 	    NET - Neural network from which X can be obtained (ignored).
% 
% 	  MAE(CODE) return useful information for each CODE string:
% 	    'deriv'     - Returns name of derivative function.
% 	    'name'      - Returns full name.
% 	    'pnames'    - Returns names of training parameters.
% 	    'pdefaults' - Returns default training parameters.
% 	
% 	Examples
% 
% 	  Here a perceptron is created with a 1-element input ranging
% 	  from -10 to 10, and one neuron.
% 
% 	    net = newp([-10 10],1);
% 
% 	  Here the network is given a batch of inputs P.  The error
% 	  is calculated by subtracting the output A from target T.
% 	  Then the mean absolute error is calculated.
% 
% 	    p = [-10 -5 0 5 10];
% 	    t = [0 0 1 1 1];
% 	    y = sim(net,p)
% 	    e = t-y
% 	    perf = mae(e)
% 
% 	  Note that MAE can be called with only one argument because
% 	  the other arguments are ignored.  MAE supports those arguments
% 	  to conform to the standard performance function argument list.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses MAE with NEWP.
% 
% 	  To prepare a custom network to be trained with MAE, set
% 	  NET.performFcn to 'mae'.  This will automatically set
% 	  NET.performParam to the empty matrix [], as MAE has no
% 	  performance parameters.
% 
% 	  In either case, calling TRAIN or ADAPT will result
% 	  in MAE being used to calculate performance.
% 
% 	  See NEWP for examples.
% 
% 	

function mse
%MATLAB Tour Partial Function Help:  nnt_con
%
% MSE Mean squared error performance function.
% 
% 	Syntax
% 
% 	  perf = mse(e,x,pp)
% 	  perf = mse(e,net,pp)
% 	  info = mse(code)
% 
% 	Description
% 
% 	  MSE is a network performance function.  It measures the
% 	  network's performance according to the mean of squared errors.
% 	
% 	  MSE(E,X,PP) takes from one to three arguments,
% 	    E  - Matrix or cell array of error vector(s).
% 	    X  - Vector of all weight and bias values (ignored).
% 	    PP - Performance parameters (ignored).
%      and returns the mean squared error.
% 
% 	  MSE(E,NET,PP) can take an alternate argument to X,
% 	    NET - Neural network from which X can be obtained (ignored).
% 
% 	  MSE(CODE) returns useful information for each CODE string:
% 	    'deriv'     - Returns name of derivative function.
% 	    'name'      - Returns full name.
% 	    'pnames'    - Returns names of training parameters.
% 	    'pdefaults' - Returns default training parameters.
% 	
% 	Examples
% 
% 	  Here a two layer feed-forward network is created with a 1-element
% 	  input ranging from -10 to 10, four hidden TANSIG neurons, and one
% 	  PURELIN output neuron.
% 
% 	    net = newff([-10 10],[4 1],{'tansig','purelin'});
% 
% 	  Here the network is given a batch of inputs P.  The error
% 	  is calculated by subtracting the output A from target T.
% 	  Then the mean squared error is calculated.
% 
% 	    p = [-10 -5 0 5 10];
% 	    t = [0 0 1 1 1];
% 	    y = sim(net,p)
% 	    e = t-y
% 	    perf = mse(e)
% 
% 	  Note that MSE can be called with only one argument because the
% 	  other arguments are ignored.  MSE supports those ignored arguments
% 	  to conform to the standard performance function argument list.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses MSE with NEWFF,
% 	  NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with MSE set
% 	  NET.performFcn to 'mse'.  This will automatically set
% 	  NET.performParam to the empty matrix [], as MSE has no
% 	  performance parameters.
% 
% 	  In either case, calling TRAIN or ADAPT will result
% 	  in MSE being used to calculate performance.
% 
% 	  See NEWFF or NEWCF for examples.
% 
% 	

function msereg
%MATLAB Tour Partial Function Help:  nnt_con
%
% MSEREG Mean squared error with regularization performance function.
% 
% 	Syntax
% 
% 	  perf = msereg(e,x,pp)
% 	  perf = msereg(e,net)
% 	  info = msereg(code)
% 
% 	Description
% 
% 	  MSEREG is a network performance function.  It measures
% 	  network performance as the weight sum of two factors:
% 	  the mean squared error and the mean squared weights and biases.
% 	
% 	  MSEREG(E,X,PP) takes from three arguments,
% 	    E  - Matrix or cell array of error vector(s).
% 	    X  - Vector of all weight and bias values.
% 	    PP - Performance parameter.
% 	  where PP defines one performance parameter,
% 	    PP.ratio - Relative importance of errors vs. weight and bias values.
%      and returns the sum of mean squared errors (times PP.ratio) with the
% 	  mean squared weight and bias values (times 1-PP.ratio).
% 
% 	  The errors E can be given in cell array form,
% 	    E - NtxTS cell array, each element E{i,ts} is a VixQ matrix or [].
% 	  or as a matrix,
% 	    E - (sum of Vi)xQ matrix
% 	  where:
% 	    Nt = net.numTargets
% 	    TS = number of time steps
% 	    Q  = batch size
% 	    Vi = net.targets{i}.size
% 
% 	  MSEREG(E,NET) takes an alternate argument to X and PP,
% 	    NET - Neural network from which X and PP can be obtained.
% 
% 	  MSEREG(CODE) returns useful information for each CODE string:
% 	    'deriv'     - Returns name of derivative function.
% 	    'name'      - Returns full name.
% 	    'pnames'    - Returns names of training parameters.
% 	    'pdefaults' - Returns default training parameters.
% 	
% 	Examples
% 
% 	  Here a two layer feed-forward is created with a 1-element input
% 	  ranging from -2 to 2, four hidden TANSIG neurons, and one
% 	  PURELIN output neuron.
% 
% 	net = newff([-2 2],[4 1],{'tansig','purelin'},'trainlm','learngdm','msereg');
% 
% 	  Here the network is given a batch of inputs P.  The error is
% 	  calculated by subtracting the output A from target T. Then the
% 	  mean squared error is calculated using a ratio of 20/(20+1).
% 	  (Errors are 20 times as important as weight and bias values).
% 
% 	    p = [-2 -1 0 1 2];
% 	    t = [0 1 1 1 0];
% 	    y = sim(net,p)
% 	    e = t-y
% 	    net.performParam.ratio = 20/(20+1);
% 	    perf = msereg(e,net)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses MSEREG with NEWFF,
% 	  NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with MSEREG, set
% 	  NET.performFcn to 'msereg'.  This will automatically set
% 	  NET.performParam to MSEREG's default performance parameters.
% 
% 	  In either case, calling TRAIN or ADAPT will result
% 	  in MSEREG being used to calculate performance.
% 
% 	  See NEWFF or NEWCF for examples.
% 
% 	

function sse
%MATLAB Tour Partial Function Help:  nnt_con
%
% SSE Sum squared error performance function.
% 
% 	Syntax
% 
% 	  perf = sse(e,x,pp)
% 	  perf = sse(e,net,pp)
% 	  info = sse(code)
% 
% 	Description
% 
% 	  SSE is a network performance function.  It measures
% 	  performance according to the sum of squared errors.
% 	
% 	  SSE(E,X,PP) takes from one to three arguments,
% 	    E  - Matrix or cell array of error vector(s).
% 	    X  - Vector of all weight and bias values (ignored).
% 	    PP - Performance parameters (ignored).
%      and returns the sum squared error.
% 
% 	  SSE(E,NET,PP) can take an alternate argument to X,
% 	    NET - Neural network from which X can be obtained (ignored).
% 
% 	  SSE(CODE) returns useful information for each CODE string:
% 	    'deriv'     - Returns name of derivative function.
% 	    'name'      - Returns full name.
% 	    'pnames'    - Returns names of training parameters.
% 	    'pdefaults' - Returns default training parameters.
% 	
% 	Examples
% 
% 	  Here a two layer feed-forward is created with a 1-element input
% 	  ranging from -10 to 10, four hidden TANSIG neurons, and one
% 	  PURELIN output neuron.
% 
% 	    net = newff([-10 10],[4 1],{'tansig','purelin'});
% 
% 	  Here the network is given a batch of inputs P.  The error
% 	  is calculated by subtracting the output A from target T.
% 	  Then the sum squared error is calculated.
% 
% 	    p = [-10 -5 0 5 10];
% 	    t = [0 0 1 1 1];
% 	    y = sim(net,p)
% 	    e = t-y
% 	    perf = sse(e)
% 
% 	  Note that SSE can be called with only one argument because
% 	  the other arguments are ignored.  SSE supports those arguments
% 	  to conform to the standard performance function argument list.
% 
% 	Network Use
% 
% 	  To prepare a custom network to be trained with SSE set
% 	  NET.performFcn to 'sse'.  This will automatically set
% 	  NET.performParam to the empty matrix [], as SSE has no
% 	  performance parameters.
% 
% 	  Calling TRAIN or ADAPT will result in SSE being used to calculate
% 	  performance.
% 
% 	

function dmae
%MATLAB Tour Partial Function Help:  nnt_con
%
% DMAE Mean absolute error performance derivative function.
% 
% 	Syntax
% 
% 	  dPerf_dE = dmae('e',E,X,perf,PP)
% 	  dPerf_dX = dmae('x',E,X,perf,PP)
% 
% 	Description
% 
% 	  DMAE is the derivative function for MAE.
% 
% 	  DMAE('d',E,X,PERF,PP) takes these arguments,
% 	    E    - Matrix or cell array of error vector(s).
% 	    X    - Vector of all weight and bias values.
% 	    Perf - Network performance (ignored).
% 	    PP   - Performance parameters (ignored).
% 	  and returns the derivative dPerf/dE.
% 
% 	  DMAE('x',E,X,PERF,PP) returns the derivative dPerf/dX.
% 
% 	Examples
% 
% 	  Here we define E and X for a network with one
% 	  3-element output and six weight and bias values.
% 
% 	    E = {[1; -2; 0.5]};
% 	    X = [0; 0.2; -2.2; 4.1; 0.1; -0.2];
% 
% 	  Here we calculate the network's mean absolute error
% 	  performance, and derivatives of performance.
% 
% 	    perf = mae(E)
% 	    dPerf_dE = dmae('e',E,X)
% 	    dPerf_dX = dmae('x',E,X)
% 
% 	  Note that MAE can be called with only one argument and
% 	  DMAE with only three arguments because the other arguments
% 	  are ignored.  The other arguments exist so that MAE and
% 	  DMAE conform to standard performance function argument lists.
% 
% 	

function dmse
%MATLAB Tour Partial Function Help:  nnt_con
%
% DMSE Mean squared error performance derivatives function.
% 
% 	Syntax
% 
% 	  dPerf_dE = dmse('e',E,X,perf,PP)
% 	  dPerf_dX = dmse('x',E,X,perf,PP)
% 
% 	Description
% 
% 	  DMSE is the derivative function for MSE.
% 
% 	  DMSE('d',E,X,PERF,PP) takes these arguments,
% 	    E    - Matrix or cell array of error vector(s).
% 	    X    - Vector of all weight and bias values.
% 	    Perf - Network performance (ignored).
% 	    PP   - Performance parameters (ignored).
% 	  and returns the derivative dPerf/dE.
% 
% 	  DMSE('x',E,X,PERF,PP) returns the derivative dPerf/dX.
% 
% 	Examples
% 
% 	  Here we define E and X for a network with one
% 	  3-element output and six weight and bias values.
% 
% 	    E = {[1; -2; 0.5]};
% 	    X = [0; 0.2; -2.2; 4.1; 0.1; -0.2];
% 
% 	  Here we calculate the network's mean squared error
% 	  performance, and derivatives of performance.
% 
% 	    perf = mse(E)
% 	    dPerf_dE = dmse('e',E,X)
% 	    dPerf_dX = dmse('x',E,X)
% 
% 	  Note that MSE can be called with only one argument and
% 	  DMSE with only three arguments because the other arguments
% 	  are ignored.  The other arguments exist so that MSE and
% 	  DMSE conform to standard performance function argument lists.
% 
% 	

function dmsereg
%MATLAB Tour Partial Function Help:  nnt_con
%
% DMSEREG Mean squared error w/reg performance derivative function.
% 
% 	Syntax
% 
% 	  dPerf_dE = dmsereg('e',E,X,perf,PP)
% 	  dPerf_dX = dmsereg('x',E,X,perf,PP)
% 
% 	Description
% 
% 	  DMSEREG is the derivative function for MSEREG.
% 
% 	  DMSEREG('d',E,X,PERF,PP) takes these arguments,
% 	    E    - Matrix or cell array of error vector(s).
% 	    X    - Vector of all weight and bias values.
% 	    Perf - Network performance (ignored).
% 	    PP   - MSE performance parameters.
% 	  where PP defines one performance parameter,
% 	    PP.ratio - Relative importance of errors vs. weight and bias values.
% 	  and returns the derivative dPerf/dE.
% 
% 	  DMSEREG('x',E,X,PERF) returns the derivative dPerf/dX.
% 
% 	  MSE has only one performance parameter
% 
% 	Examples
% 
% 	  Here we define an error E and X for a network with one
% 	  3-element output and six weight and bias values.
% 
% 	    E = {[1; -2; 0.5]};
% 	    X = [0; 0.2; -2.2; 4.1; 0.1; -0.2];
% 
% 	  Here the ratio performance parameter is defined so
% 	  that squared errors are 5 times as important as
% 	  squared weight and bias values.
% 
% 	    pp.ratio = 5/(5+1);
% 
% 	  Here we calculate the network's mean performance,
% 	  and derivatives of performance.
% 
% 	    perf = msereg(E,X,pp)
% 	    dPerf_dE = dmsereg('e',E,X,perf,pp)
% 	    dPerf_dX = dmsereg('x',E,X,perf,pp)
% 
% 	

function dsse
%MATLAB Tour Partial Function Help:  nnt_con
%
% DSSE Sum squared error performance derivative function.
% 
% 
% 	Syntax
% 
% 	  dPerf_dE = dsse('e',E,X,perf,PP)
% 	  dPerf_dX = dsse('x',E,X,perf,PP)
% 
% 	Description
% 
% 	  DSSE is the derivative function for SSE.
% 
% 	  DSSE('d',E,X,PERF,PP) takes these arguments,
% 	    E    - Matrix or cell array of error vector(s).
% 	    X    - Vector of all weight and bias values.
% 	    Perf - Network performance (ignored).
% 	    PP   - Performance parameters (ignored).
% 	  and returns the derivative dPerf/dE.
% 
% 	  DSSE('x',E,X,PERF,PP) returns the derivative dPerf/dX.
% 
% 	Examples
% 
% 	  Here we define an error E and X for a network with one
% 	  3-element output and six weight and bias values.
% 
% 	    E = {[1; -2; 0.5]};
% 	    X = [0; 0.2; -2.2; 4.1; 0.1; -0.2];
% 
% 	  Here we calculate the network's sum squared error
% 	  performance, and derivatives of performance.
% 
% 	    perf = sse(E)
% 	    dPerf_dE = dsse('e',E,X)
% 	    dPerf_dX = dsse('x',E,X)
% 
% 	  Note that SSE can be called with only one argument and
% 	  DSSE with only three arguments because the other arguments
% 	  are ignored.  The other arguments exist so that SSE and
% 	  DSSE conform to standard performance function argument lists.
% 
% 	

function hintonw
%MATLAB Tour Partial Function Help:  nnt_con
%
% HINTONW Hinton graph of weight matrix.
% 
% 	Syntax
% 
% 	  hintonw(W,maxw,minw)
% 
% 	Description
% 	
% 	  HINTONW(W,MAXW,MINW) takes these inputs,
% 	    W    - SxR weight matrix
% 	    MAXW - Maximum weight, default = max(max(abs(W))).
% 	    MINW - Minimum weight, default = M1/100.
% 	  and displays a weight matrix represented as a grid of squares.
% 	
% 	  Each square's AREA represents a weight's magnitude.
% 	  Each square's COLOR represents a weight's sign.
% 	  RED for negative weights, GREEN for positive.
% 
% 	Examples
% 
% 	  W = rands(4,5);
% 	  hintonw(W)
% 	
% 	

function hintonwb
%MATLAB Tour Partial Function Help:  nnt_con
%
% HINTONWB Hinton graph of weight matrix and bias vector.
% 
% 	Syntax
% 
% 	  hintonwb(W,b,maxw,minw)
% 
% 	Description
% 	
% 	  HINTONWB(W,B,M1,M2)
% 	    W    - SxR weight matrix
% 	    B    - Sx1 bias vector.
% 	    MAXW - Maximum weight, default = max(max(abs(W))).
% 	    MINW - Minimum weight, default = M1/100.
% 	  and displays a weight matrix and a bias vector represented
% 	  as a grid of squares.
% 	
% 	  Each square's AREA represents a weight's magnitude.
% 	  Each square's COLOR represents a weight's sign.
% 	  RED for negative weights, GREEN for positive.
% 
% 	Examples
% 
% 	  W = rands(4,5);
% 	  b = rands(4,1);
% 	  hintonwb(W,b)
% 	
% 	

function plotbr
%MATLAB Tour Partial Function Help:  nnt_con
%
% PLOTBR Plot network performance for Bayesian regularization training.
% 
% 	Syntax
% 
% 	  plotbr(tr,name,epoch)
% 
% 	Description
% 
% 	  PLOTBR(TR,NAME,EPOCH) takes these inputs,
% 	    TR - Training record returned by train.
% 	    NAME - Training function name, default = ''.
% 	    EPOCH - Number of epochs, default = length of training record.
% 	  and plots the training sum squared error, the sum squared weights
% 	  and the effective number of parameters.
% 
% 	Example
% 
% 	  Here are input values P and associated targets T.
% 
%        p = [-1:.05:1];
%        t = sin(2*pi*p)+0.1*randn(size(p));
% 
% 	  The code below creates a network and trains it on this problem.
% 
%        net=newff([-1 1],[20,1],{'tansig','purelin'},'trainbr');
% 	    [net,tr] = train(net,p,t);
% 
% 	  During training PLOTBR was called to display the training
% 	  record.  You can also call PLOTBR directly with the final
% 	  training record TR, as shown below.
% 
% 	    plotbr(tr)

function plotes
%MATLAB Tour Partial Function Help:  nnt_con
%
% PLOTES Plot the error surface of a single input neuron.
% 
% 	Syntax
% 
% 	  plotes(wv,bv,es,v)
% 
% 	Description
% 	
% 	  PLOTES(WV,BV,ES,V) takes these arguments,
% 	    WV - 1xN row vector of values of W.
% 	    BV - 1xM row vector of values of B.
% 	    ES - MxN matrix of error vectors.
% 	    V  - View, default = [-37.5, 30].
% 	  and plots the error surface with a contour underneath.
% 	
% 	  Calculate the error surface ES with ERRSURF.
% 
% 	Examples
% 	
% 	  p = [3 2];
% 	  t = [0.4 0.8];
% 	  wv = -4:0.4:4; bv = wv;
% 	  ES = errsurf(p,t,wv,bv,'logsig');
% 	  plotes(wv,bv,ES,[60 30])
% 	         
% 	

function plotpc
%MATLAB Tour Partial Function Help:  nnt_con
%
% PLOTPC Plot a classification line on a perceptron vector plot.
% 
% 	Syntax
% 
% 	  plotpc(W,b)
% 
% 	Description
% 
% 	  PLOTPC(W,B) takes these inputs,
% 	    W - SxR weight matrix (R must be 3 or less).
% 	    B - Sx1 bias vector.
% 	  and returns a handle to a plotted classification line.
% 	
% 	  PLOTPC(W,B,H) takes these inputs,
% 	    H - Handle to last plotted line.
% 	  and deletes the last line before plotting the new one.
% 	
% 	  This function does not change the current axis and is intended
% 	  to be called after PLOTPV.
% 
% 	Example
% 
% 	  The code below defines and plots the inputs and targets for a
% 	  perceptron:
% 
% 	    p = [0 0 1 1; 0 1 0 1];
% 	    t = [0 0 0 1];
% 	    plotpv(p,t)
% 
% 	  The following code creates a perceptron with inputs ranging
% 	  over the values in P, assigns values to its weights
% 	  and biases, and plots the resulting classification line.
% 
% 	    net = newp(minmax(p),1);
% 	    net.iw{1,1} = [-1.2 -0.5];
% 	    net.b{1} = 1;
% 	    plotpc(net.iw{1,1},net.b{1})
% 
% 	

function plotpv
%MATLAB Tour Partial Function Help:  nnt_con
%
% PLOTPV Plot perceptron input/target vectors.
% 
% 	Syntax
% 
% 	  plotpv(p,t)
% 
% 	Description
% 	
% 	  PLOTPV(P,T) take these inputs,
% 	    P - RxQ matrix of input vectors (R must be 3 or less).
% 	    T - SxQ matrix of binary target vectors (S must be 3 or less).
% 	  and plots column vectors in P with markers based on T.
% 	
% 	  PLOTPV(P,T,V) takes an additional input,
% 	    V - Graph limits = [x_min x_max y_min y_max]
% 	  and plots the column vectors with limits set by V.
% 
% 	Example
% 
% 	  The code below defines and plots the inputs and targets
% 	  for a perceptron:
% 
% 	    p = [0 0 1 1; 0 1 0 1];
% 	    t = [0 0 0 1];
% 	    plotpv(p,t)
% 
% 	  The following code creates a perceptron with inputs ranging
% 	  over the values in P, assigns values to its weights
% 	  and biases, and plots the resulting classification line.
% 
% 	    net = newp(minmax(p),1);
% 	    net.iw{1,1} = [-1.2 -0.5];
% 	    net.b{1} = 1;
% 	    plotpc(net.iw{1,1},net.b{1})
% 
% 	

function plotep
%MATLAB Tour Partial Function Help:  nnt_con
%
% PLOTEP Plot a weight-bias position on an error surface.
% 
% 	Syntax
% 
% 	  h = plotep(w,b,e)
% 	  h = plotep(w,b,e,h)
% 
% 	Description
% 
% 	  PLOTEP is used to show network learning on a plot
% 	    already created by PLOTES.
% 	
% 	  PLOTEP(W,B,E) takes these arguments
% 	    W - Current weight value.
% 	    B - Current bias value.
% 	    E - Current error.
% 	  and returns a vector H containing information for
% 	  continuing the plot.
% 	
% 	  PLOTEP(W,B,E,H) continues plotting using the vector H,
% 	  returned by the last call to PLOTEP.
% 	
% 	  H contains handles to dots plotted on the error surface,
% 	  so they can be deleted next time, as well as points on
% 	  the error contour, so they can be connected.
% 	
% 	

function plotperf
%MATLAB Tour Partial Function Help:  nnt_con
%
% PLOTPERF Plot network performance.
% 
% 	Syntax
% 
% 	  plotperf(tr,goal,name,epoch)
% 
% 	Description
% 
% 	  PLOTPERF(TR,GOAL,NAME,EPOCH) takes these inputs,
% 	    TR - Training record returned by train.
% 	    GOAL - Performance goal, default = NaN.
% 	    NAME - Training function name, default = ''.
% 	    EPOCH - Number of epochs, default = length of training record.
% 	  and plots the training performance, and if available, the performance
% 	  goal, validation performance, and test performance.
% 
% 	Example
% 
% 	  Here are 8 input values P and associated targets T, plus a like
% 	  number of validation inputs VV.P and targets VV.T.
% 
% 	    P = 1:8; T = sin(P);
% 	    VV.P = P; VV.T = T+rand(1,8)*0.1;
% 
% 	  The code below creates a network and trains it on this problem.
% 
% 	    net = newff(minmax(P),[4 1],{'tansig','tansig'});
% 	    [net,tr] = train(net,P,T,[],[],VV);
% 
% 	  During training PLOTPERF was called to display the training
% 	  record.  You can also call PLOTPERF directly with the final
% 	  training record TR, as shown below.
% 
% 	    plotperf(tr)

function plotsom
%MATLAB Tour Partial Function Help:  nnt_con
%
% PLOTSOM Plot self-organizing map.
% 
% 	Syntax
% 
% 	  plotsom(pos)
% 	  plotsom(W,d,nd)
% 
% 	Description
% 
% 	  PLOTSOM(POS) takes one argument,
% 	    POS - NxS matrix of S N-dimension neural positions.
% 	  and plots the neuron positions with red dots, linking
% 	  the neurons within a Euclidean distance of 1.
% 
% 	  PLOTSOM(W,D,ND) takes three arguments,
% 	    W  - SxR weight matrix.
% 	    D  - SxS distance matrix.
% 	    ND - Neighborhood distance, default = 1.
% 	  and plots the neuron's weight vectors with connections
% 	  between weight vectors whose neurons are within a
% 	  distance of 1.
% 
% 	Examples
% 
% 	  Here are some neat plots of various layer topologies:
% 
% 	    pos = hextop(5,6); plotsom(pos)
% 	    pos = gridtop(4,5); plotsom(pos)
% 	    pos = randtop(18,12); plotsom(pos)
% 	    pos = gridtop(4,5,2); plotsom(pos)
% 	    pos = hextop(4,4,3); plotsom(pos)
% 
% 	  See NEWSOM for an example of plotting a layer's
% 	  weight vectors with the input vectors they map.
% 
% 	

function plotv
%MATLAB Tour Partial Function Help:  nnt_con
%
% PLOTV Plot vectors as lines from the origin.
% 
% 	Syntax
% 
% 	  plotv(m,t)
% 
% 	Description
% 
% 	  PLOTV(M,T) takes two inputs,
% 	    M - RxQ matrix of Q column vectors with R elements.
% 	    T - (optional) the line plotting type, default = '-'.
% 	  and plots the column vectors of M.
% 	
% 	  R must be 2 or greater.  If R is greater than two,
% 	  only the first two rows of M are used for the plot.
% 
% 	Examples
% 
% 	  plotv([-.4 0.7 .2; -0.5 .1 0.5],'-')

function plotvec
%MATLAB Tour Partial Function Help:  nnt_con
%
% PLOTVEC Plot vectors with different colors.
% 
% 	Syntax
% 
% 	  plotvec(x,c,m)
% 
% 	Description
% 
% 	  PLOTVEC(X,C,M) takes these inputs,
% 	    X - Matrix of (column) vectors.
% 	    C - Row vector of color coordinate.
% 	    M - Marker, default = '+'.
% 	  and plots each ith vector in X with a marker M, using the
% 	  ith value in C as the color coordinate.
% 	
% 	  PLOTVEC(X) only takes a matrix X and plots each ith
% 	  vector in X with marker '+' using the index i as the
% 	  color coordinate.
% 	
% 	Examples
% 
% 	  x = [0 1 0.5 0.7; -1 2 0.5 0.1];
% 	  c = [1 2 3 4];
% 	  plotvec(x,c)

function prestd
%MATLAB Tour Partial Function Help:  nnt_con
%
% PRESTD Preprocesses the data so that the mean is 0 and the standard deviation is 1.
% 	
% 	Syntax
% 
% 	  [pn,meanp,stdp,tn,meant,stdt] = prestd(p,t)
%      [pn,meanp,stdp] = prestd(p)
% 
% 	Description
% 	
% 	  PRESTD preprocesses the network training
% 	  set by normalizing the inputs and targets so that
%      they have means of zero and standard deviations of 1.
% 	
% 	  PRESTD(P,T) takes these inputs,
% 	    P - RxQ matrix of input (column) vectors.
%        T - SxQ matrix of target vectors.
% 	  and returns,
%        PN    - RxQ matrix of normalized input vectors
%        MEANP - Rx1 vector containing standard deviations for each P
%        STDP  - Rx1 vector containing standard deviations for each P
%        TN    - SxQ matrix of normalized target vectors
%        MEANT - Sx1 vector containing standard deviations for each T
%        STDT  - Sx1 vector containing standard deviations for each T
% 		
% 	Examples
% 
% 	  Here is the code to normalize a given data set so
%      that the inputs and targets will have means
%      of zero and standard deviations of 1.
% 	
% 	    p = [-0.92 0.73 -0.47 0.74 0.29; -0.08 0.86 -0.67 -0.52 0.93];
%        t = [-0.08 3.4 -0.82 0.69 3.1];
% 	    [pn,meanp,stdp,tn,meant,stdt] = prestd(p,t);
% 
%      If you just want to normalize the input:
% 
%        [pn,meanp,stdp] = prestd(p);
% 
% 	Algorithm
% 
%      pn = (p-meanp)/stdp;
% 
% 	

function poststd
%MATLAB Tour Partial Function Help:  nnt_con
%
% POSTSTD Postprocesses data which has been preprocessed by PRESTD.
% 	
% 	Syntax
% 
% 	  [p,t] = poststd(pn,meanp,stdp,tn,meant,stdt)
%      [p] = poststd(pn,meanp,stdp)
% 
% 	Description
% 	
% 	  POSTSTD postprocesses the network training
% 	  set which was preprocessed by PRESTD.  It converts
%      the data back into unnormalized units.
% 	
% 	  POSTSTD takes these inputs,
%        PN    - RxQ matrix of normalized input vectors
%        MEANP - Rx1 vector containing standard deviations for each P
%        STDP  - Rx1 vector containing standard deviations for each P
%        TN    - SxQ matrix of normalized target vectors
%        MEANT - Sx1 vector containing standard deviations for each T
%        STDT  - Sx1 vector containing standard deviations for each T
% 	  and returns,
% 	    P - RxQ matrix of input (column) vectors.
%        T - SxQ matrix of target vectors.
% 		
% 	Examples
% 
% 	  In this example we normalize a set of training data with
%      PRESTD, create and train a network using the normalized
%      data, simulate the network, unnormalize the output of the
%      network using POSTSTD, and perform a linear regression between 
%      the network outputs (unnormalized) and the targets to check the
%      quality of the network training.
% 	
% 	    p = [-0.92 0.73 -0.47 0.74 0.29; -0.08 0.86 -0.67 -0.52 0.93];
%        t = [-0.08 3.4 -0.82 0.69 3.1];
% 	    [pn,meanp,stdp,tn,meant,stdt] = prestd(p,t);
%        net = newff(minmax(pn),[5 1],{'tansig' 'purelin'},'trainlm');
%        net = train(net,pn,tn);
%        an = sim(net,pn);
%        a = poststd(an,meant,stdt);
%        [m,b,r] = postreg(a,t);
% 
% 	Algorithm
% 
%      p = stdp*pn + meanp;
% 
% 	

function trastd
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRASTD Preprocesses data using a precalculated mean and standard deviation.
% 	
% 	Syntax
% 
% 	  [pn] = trastd(p,meanp,stdp)
% 
% 	Description
% 	
% 	  TRASTD preprocesses the network training set using the mean and 
% 	  standard deviation that were previously computed by PRESTD.
%      This function needs to be used when a network has been trained 
%      using data normalized by PRESTD.  All subsequent inputs to the  
%      network need to be transformed using the same normalization.
% 	
% 	  TRASTD(P,T) takes these inputs,
% 	    P - RxQ matrix of input (column) vectors.
%        MEANP - Rx1 vector containing the original means for each input
%        STDP  - Rx1 vector containing the original standard deviations for each input
% 	  and returns,
%        PN    - RxQ matrix of normalized input vectors
% 		
% 	Examples
% 
% 	  Here is the code to normalize a given data set so
%      that the inputs and targets will have means
%      of zero and standard deviations of 1.
% 	
% 	    p = [-0.92 0.73 -0.47 0.74 0.29; -0.08 0.86 -0.67 -0.52 0.93];
%        t = [-0.08 3.4 -0.82 0.69 3.1];
% 	    [pn,meanp,stdp,tn,meant,stdt] = prestd(p,t);
%        net = newff(minmax(pn),[5 1],{'tansig' 'purelin'},'trainlm');
%        net = train(net,pn,tn);
% 
%      If we then receive new inputs to apply to the trained network, we will 
%      use TRASTD to transform them first. Then the transformed inputs can be
%      used to simulate the previously trained network.  The network output 
%      must also be unnormalized using POSTSTD.
% 
%        p2 = [1.5 -0.8;0.05 -0.3];
%        [p2n] = trastd(p2,meanp,stdp);
%        an = sim(net,pn);
%        [a] = poststd(an,meant,stdt);
% 
% 	Algorithm
% 
%      pn = (p-meanp)/stdp;
% 
% 	

function premnmx
%MATLAB Tour Partial Function Help:  nnt_con
%
% PREMNMX Preprocesses data so that minimum is -1 and maximum is 1.
% 	
% 	Syntax
% 
% 	  [pn,minp,maxp,tn,mint,maxt] = premnmx(p,t)
%      [pn,minp,maxp] = premnmx(p)
% 
% 	Description
% 	
% 	  PREMNMX preprocesses the network training
% 	  set by normalizing the inputs and targets so that
%      they fall in the interval [-1,1].
% 	
% 	  PREMNMX(P,T) takes these inputs,
% 	    P - RxQ matrix of input (column) vectors.
%        T - SxQ matrix of target vectors.
% 	  and returns,
%        PN  - RxQ matrix of normalized input vectors
%        MINP- Rx1 vector containing minimums for each P
%        MAXP- Rx1 vector containing maximums for each P
%        TN  - SxQ matrix of normalized target vectors
%        MINT- Sx1 vector containing minimums for each T
%        MAXT- Sx1 vector containing maximums for each T
% 		
% 	Examples
% 
% 	  Here is how to normalize a given data set so
%      that the inputs and targets will fall in the
%      range [-1,1].
% 	
% 	    p = [-10 -7.5 -5 -2.5 0 2.5 5 7.5 10];
%        t = [0 7.07 -10 -7.07 0 7.07 10 7.07 0];
% 	    [pn,minp,maxp,tn,mint,maxt] = premnmx(p,t);
% 
%      If you just want to normalize the input:
% 
%        [pn,minp,maxp] = premnmx(p);
% 
% 	Algorithm
% 
%      pn = 2*(p-minp)/(maxp-minp) - 1;
% 
% 	

function postmnmx
%MATLAB Tour Partial Function Help:  nnt_con
%
% POSTMNMX Postprocesses data which has been preprocessed by PREMNMX.
% 	
% 	Syntax
% 
% 	  [p,t] = postmnmx(pn,minp,maxp,tn,mint,maxt)
%      [p] = postmnmx(pn,minp,maxp)
% 
% 	Description
% 	
% 	  POSTMNMX postprocesses the network training
% 	  set which was preprocessed by PREMNMX.  It converts
%      the data back into unnormalized units.
% 	
% 	  POSTMNMX takes these inputs,
%        PN  - RxQ matrix of normalized input vectors
%        MINP- Rx1 vector containing minimums for each P
%        MAXP- Rx1 vector containing maximums for each P
%        TN  - SxQ matrix of normalized target vectors
%        MINT- Sx1 vector containing minimums for each T
%        MAXT- Sx1 vector containing maximums for each T
% 	  and returns,
% 	    P - RxQ matrix of input (column) vectors.
%        T - SxQ matrix of target vectors.
% 		
% 	Examples
% 
% 	  In this example we normalize a set of training data with
%      PREMNMX, create and train a network using the normalized
%      data, simulate the network, unnormalize the output of the
%      network using POSTMNMX, and perform a linear regression between 
%      the network outputs (unnormalized) and the targets to check the
%      quality of the network training.
% 	
% 	    p = [-0.92 0.73 -0.47 0.74 0.29; -0.08 0.86 -0.67 -0.52 0.93];
%        t = [-0.08 3.4 -0.82 0.69 3.1];
% 	    [pn,minp,maxp,tn,mint,maxt] = premnmx(p,t);
%        net = newff(minmax(pn),[5 1],{'tansig' 'purelin'},'trainlm');
%        net = train(net,pn,tn);
%        an = sim(net,pn);
%        [a] = postmnmx(an,mint,maxt);
%        [m,b,r] = postreg(a,t);
% 
% 	Algorithm
% 
%      p = 0.5(pn+1)*(maxp-minp) + minp;
% 
% 	

function tramnmx
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAMNMX Transform data using a precalculated min and max.
% 	
% 	Syntax
% 
%      [pn] = tramnmx(p,minp,maxp)
% 
% 	Description
% 	
% 	  TRAMNMX transforms the network input set using 
% 	  minimum and maximum values that were previously 
%      computed by PREMNMX.  This function needs to be 
%      used when a network has been trained using data normalized 
%      by PREMNMX.  All subsequent inputs to the network need to
%      be transformed using the same normalization.
% 	
% 	  TRAMNMX(P,MINP,MAXP) takes these inputs,
% 	    P - RxQ matrix of input (column) vectors.
%        MINP- Rx1 vector containing original minimums for each input
%        MAXP- Rx1 vector containing original maximums for each input
% 	  and returns,
%        PN  - RxQ matrix of normalized input vectors
% 		
% 	Example
% 
% 	  Here is the code to normalize a given data set so
%      that the inputs and targets will fall in the
%      range [-1,1], using PREMNMX, and the code to train a network
%      with the normalized data.
% 	
% 	    p = [-10 -7.5 -5 -2.5 0 2.5 5 7.5 10];
%        t = [0 7.07 -10 -7.07 0 7.07 10 7.07 0];
% 	    [pn,minp,maxp,tn,mint,maxt] = premnmx(p,t);
%        net = newff(minmax(pn),[5 1],{'tansig' 'purelin'},'trainlm');
%        net = train(net,pn,tn);
% 
%      If we then receive new inputs to apply to the trained
%      network, we will use TRAMNMX to transform them
%      first. Then the transformed inputs can be used
%      to simulate the previously trained network.  The
%      network output must also be unnormalized using
%      POSTMNMX.
% 
%        p2 = [4 -7];
%        [p2n] = tramnmx(p2,minp,maxp);
%        an = sim(net,pn);
%        [a] = postmnmx(an,mint,maxt);
% 
% 	Algorithm
% 
%      pn = 2*(p-minp)/(maxp-minp) - 1;
% 
% 	

function prepca
%MATLAB Tour Partial Function Help:  nnt_con
%
% PREPCA Principal component analysis.
% 	
% 	Syntax
% 
% 	  [ptrans,transMat] = prepca(P,min_frac)
% 
% 	Description
% 	
% 	  PREPCA preprocesses the network input training
% 	  set by applying a principal component analysis.
%      This analysis transforms the input data so that
%      the elements of the input vectors will be uncorrelated.
%      In addition, the size of the input vectors may be
%      reduced by retaining only those components which
%      contribute more than a specified fraction (min_frac) of the
%      total variation in the data set.
% 	
% 	  PREPCA(p,min_frac) takes these inputs:
% 	    P        - RxQ matrix of centered input (column) vectors.
%        min_frac - Minimum fraction variance component to keep.
% 	  and returns:
%        Ptrans   - Transformed data set.
%        TransMat - Transformation matrix.
% 		
% 	Examples
% 
% 	  Here is the code to perform a principal component analysis and
%      retain only those components which contribute more than
%      2 percent to the variance in the data set.  PRESTD is
%      called first to create zero mean data, which are needed
%      for PREPCA.
% 	
% 	    p=[-1.5 -0.58 0.21 -0.96 -0.79; -2.2 -0.87 0.31 -1.4  -1.2];
% 	    [pn,meanp,stdp] = prestd(p);
% 	    [ptrans,transMat] = prepca(pn,0.02);
% 
% 	  Since the second row of p is almost a multiple of the first
%      row, this example will produce a transformed data set which
%      contains only one row.  
% 
% 	Algorithm
% 
% 	  This routine uses singular value decomposition to compute
%      the principal components.  The input vectors are multiplied
%      by a matrix whose rows consist of the eigenvectors of the
%      input covariance matrix.  This produces transformed input 
%      vectors whose components are uncorrelated and ordered according  
%      to the magnitude of their variance.  Those components which
%      contribute only a small amount to the total variance in
%      the data set are eliminated.
%      It is assumed that the input data set has already been normalized
%      so that it has a zero mean.  The function PRESTD can be used
%      to normalize the data.
% 
% 	

function trapca
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAPCA Principal component transformation.
% 	
% 	Syntax
% 
% 	  [Ptrans] = trapca(P,TransMat)
% 
% 	Description
% 	
% 	  TRAPCA preprocesses the network input training set by applying 
% 	  a principal component transformation that was previously computed 
%      by PREPCA.  This function needs to be used when a network has been 
%      trained using data normalized by PREPCA.  All subsequent inputs to 
%      the network need to be transformed using the same normalization.
% 	
% 	  TRAPCA(P,TransMat) takes these inputs,
% 	    P        - RxQ matrix of centered input (column) vectors.
%        TransMat - Transformation matrix.
% 	  and returns,
%        Ptrans   - Transformed data set.
% 		
% 	Examples
% 
% 	  Here is the code to perform a principal component analysis and
%      retain only those components which contribute more than
%      2 percent to the variance in the data set.  PRESTD is
%      called first to create zero mean data, which are needed
%      for PREPCA.
% 	
% 	    p=[-1.5 -0.58 0.21 -0.96 -0.79; -2.2 -0.87 0.31 -1.4  -1.2];
%        t = [-0.08 3.4 -0.82 0.69 3.1];
% 	    [pn,meanp,stdp,tn,meant,stdt] = prestd(p,t);
% 	    [ptrans,transMat] = prepca(pn,0.02);
%        net = newff(minmax(ptrans),[5 1],{'tansig' 'purelin'},'trainlm');
%        net = train(net,ptrans,tn);
% 
%      If we then receive new inputs to apply to the trained
%      network, we will use TRASTD and TRAPCA to transform them
%      first. Then the transformed inputs can be used
%      to simulate the previously trained network.  The
%      network output must also be unnormalized using
%      POSTSTD.
% 
%        p2 = [1.5 -0.8;0.05 -0.3];
%        [p2n] = trastd(p2,meanp,stdp);
%        [p2trans] = trapca(p2n,TransMat)
%        an = sim(net,p2trans);
%        [a] = poststd(an,meant,stdt);
% 
% 	Algorithm
% 
% 	  Ptrans = TransMat*P;
% 
% 	

function postreg
%MATLAB Tour Partial Function Help:  nnt_con
%
% POSTREG Postprocesses the trained network response with a linear regression.
% 	
% 	Syntax
% 
% 	  [m,b,r] = postreg(A,T)
% 
% 	Description
% 	
% 	  POSTREG postprocesses the network training
% 	  set by performing a linear regression between one element
%      of the network response and the corresponding target.
% 	
% 	  POSTREG(A,T) takes these inputs,
% 	    A - 1xQ array of network outputs. One element of the network output.
%        T - 1xQ array of targets. One element of the target vector.
% 	  and returns,
%        M - Slope of the linear regression.
%        B - Y intercept of the linear regression.
%        R - Regression R-value.  R=1 means perfect correlation.
% 		
% 	Example
% 
% 	  In this example we normalize a set of training data with
%      PRESTD, perform a principal component transformation on
%      the normalized data, create and train a network using the pca
%      data, simulate the network, unnormalize the output of the
%      network using POSTSTD, and perform a linear regression between 
%      the network outputs (unnormalized) and the targets to check the
%      quality of the network training.
% 	
% 	    p = [-0.92 0.73 -0.47 0.74 0.29; -0.08 0.86 -0.67 -0.52 0.93];
%        t = [-0.08 3.4 -0.82 0.69 3.1];
% 	    [pn,meanp,stdp,tn,meant,stdt] = prestd(p,t);
%        [ptrans,transMat] = prepca(pn,0.02);
%        net = newff(minmax(ptrans),[5 1],{'tansig' 'purelin'},'trainlm');
%        net = train(net,ptrans,tn);
%        an = sim(net,ptrans);
%        a = poststd(an,meant,stdt);
%        [m,b,r] = postreg(a,t);
% 
% 	Algorithm
% 
%      Performs a linear regression between the network response
%      and the target, and computes the correlation coefficient
%      (R value) between the network response and the target.
% 
% 	

function gensim
%MATLAB Tour Partial Function Help:  nnt_con
%
% --- help for network/gensim.m ---
%
% GENSIM Generate a SIMULINK block to simulate a neural network.
% 
% 	Syntax
% 
% 	  gensim(net,st)
% 
% 	Description
% 
% 	  GENSIM(NET,ST) takes these inputs,
% 	    NET - Neural network.
% 	    ST  - Sample time (default = 1).
% 	  and creates a SIMULINK system containing a block which
% 	  simulates neural network NET with a sampling time of ST.
% 
% 	  If NET has no input or layer delays (NET.numInputDelays
% 	  and NET.numLayerDelays are both 0) then you can use -1 for ST to
% 	  get a continuously sampling network. 
% 
% 	Example
% 
% 	  net = newff([0 1],[5 1]);
% 	  gensim(net)

function gridtop
%MATLAB Tour Partial Function Help:  nnt_con
%
% GRIDTOP Grid layer topology function.
% 
% 	Syntax
% 
% 	  pos = gridtop(dim1,dim2,...,dimN)
% 
% 	Description
% 
% 	  GRIDTOP calculates neuron positions for layers whose
% 	  neurons are arranged in an N dimensional grid.
% 
% 	  GRIDTOP(DIM1,DIM2,...,DIMN) takes N arguments,
% 	    DIMi - Length of layer in dimension i.
% 	  and returns an NxS matrix of N coordinate vectors
% 	  where S is the product of DIM1*DIM2*...*DIMN.
% 
% 	Examples
% 
% 	  This code creates and displays a two-dimensional layer
% 	  with 40 neurons arranged in a 8x5 grid.
% 
% 	    pos = gridtop(8,5); plotsom(pos)
% 
% 	  This code plots the connections between the same neurons,
% 	  but shows each neuron at the location of its weight vector.
% 	  The weights are generated randomly so the layer is
% 	  very unorganized as is evident in the following plot.
% 
% 	    W = rands(40,2); plotsom(W,dist(pos))
% 
% 	

function hextop
%MATLAB Tour Partial Function Help:  nnt_con
%
% HEXTOP Hexagonal layer topology function.
% 
% 	Syntax
% 
% 	  pos = hextop(dim1,dim2,...,dimN)
% 
% 	Description
% 
% 	  HEXTOP calculates the neuron positions for layers whose
% 	  neurons are arranged in a N dimensional hexagonal pattern.
% 
% 	  HEXTOP(DIM1,DIM2,...,DIMN) takes N arguments,
% 	    DIMi - Length of layer in dimension i.
% 	  and returns an NxS matrix of N coordinate vectors
% 	  where S is the product of DIM1*DIM2*...*DIMN.
% 
% 	Examples
% 
% 	  This code creates and displays a two-dimensional layer
% 	  with 40 neurons arranged in a 8x5 hexagonal pattern.
% 
% 	    pos = hextop(8,5); plotsom(pos)
% 
% 	  This code plots the connections between the same neurons,
% 	  but shows each neuron at the location of its weight vector.
% 	  The weights are generated randomly so that the layer is
% 	  very disorganized, as is evident in the following plot.
% 
% 	    W = rands(40,2); plotsom(W,dist(pos))
% 
% 	

function randtop
%MATLAB Tour Partial Function Help:  nnt_con
%
% RANDTOP Random layer topology function.
% 
% 	Syntax
% 
% 	  pos = randtop(dim1,dim2,...,dimN)
% 
% 	Description
% 
% 	  RANDTOP calculates the neuron positions for layers whose
% 	  neurons are arranged in an N dimensional random pattern.
% 
% 	  RANDTOP(DIM1,DIM2,...,DIMN) takes N arguments,
% 	    DIMi - Length of layer in dimension i.
% 	  and returns an NxS matrix of N coordinate vectors
% 	  where S is the product of DIM1*DIM2*...*DIMN.
% 
% 	Examples
% 
% 	  This code creates and displays a two-dimensional layer
% 	  with 192 neurons arranged in a 16x12 random pattern.
% 
% 	    pos = randtop(16,12); plotsom(pos)
% 
% 	  This code plots the connections between the same neurons,
% 	  but shows each neuron at the location of its weight vector.
% 	  The weights are generated randomly so that the layer is
% 	  very unorganized, as is evident in the plot.
% 
% 	    W = rands(192,2); plotsom(W,dist(pos))
% 
% 	

function trainbfg
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINBFG BFGS quasi-Newton backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = trainbfg(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = trainbfg(code)
% 
% 	Description
% 
% 	  TRAINBFG is a network training function that updates weight and
% 	  bias values according to the BFGS quasi-Newton method.
% 
% 	TRAINBFG(NET,Pd,Tl,Ai,Q,TS,VV,TV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	    TV  - Either empty matrix [] or structure of test vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINBFG's training parameters,
% 	  shown here with their default values:
% 	    net.trainParam.epochs          100  Maximum number of epochs to train
% 	    net.trainParam.show             25  Epochs between showing progress
% 	    net.trainParam.goal              0  Performance goal
% 	    net.trainParam.time            inf  Maximum time to train in seconds
% 	    net.trainParam.min_grad       1e-6  Minimum performance gradient
% 	    net.trainParam.max_fail          5  Maximum validation failures
%        net.trainParam.searchFcn 'srchcha'  Name of line search routine to use.
% 
%    Parameters related to line search methods (not all used for all methods):
% 	    net.trainParam.scal_tol         20  Divide into delta to determine tolerance for linear search.
% 	    net.trainParam.alpha         0.001  Scale factor which determines sufficient reduction in perf.
% 	    net.trainParam.beta            0.1  Scale factor which determines sufficiently large step size.
% 	    net.trainParam.delta          0.01  Initial step size in interval location step.
% 	    net.trainParam.gama            0.1  Parameter to avoid small reductions in performance. Usually set
%                                            to 0.1. (See use in SRCH_CHA.)
% 	    net.trainParam.low_lim         0.1  Lower limit on change in step size.
% 	    net.trainParam.up_lim          0.5  Upper limit on change in step size.
% 	    net.trainParam.maxstep         100  Maximum step length.
% 	    net.trainParam.minstep      1.0e-6  Minimum step length.
% 	    net.trainParam.bmax             26  Maximum step size.
% 
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  If TV is not [], it must be a structure of validation vectors,
% 	    TV.PD - Validation delayed inputs.
% 	    TV.Tl - Validation layer targets.
% 	    TV.Ai - Validation initial input conditions.
% 	    TV.Q  - Validation batch size.
% 	    TV.TS - Validation time steps.
% 	  which is used to test the generalization capability of the
%      trained network.
% 
% 	  TRAINBFG(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINBFG with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINBFG:
% 	  1) Set NET.trainFcn to 'trainbfg'.
% 	     This will set NET.trainParam to TRAINBFG's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINBFG.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINBFG
%      network training function is to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'trainbfg');
% 	    a = sim(net,P)
% 
% 	    % Train and Retest the Network
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,P,T);
% 	    a = sim(net,P)
% 
% 	  See NEWFF, NEWCF, and NEWELM for other examples.
% 
% 	Algorithm
% 
% 	  TRAINBFG can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
%      Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to the following:
% 
%        X = X + a*dX;
% 
%      where dX is the search direction.  The parameter a is selected
%      to minimize the performance along the search direction.  The line
%      search function searchFcn is used to locate the minimum point.
%      The first search direction is the negative of the gradient of performance.
%      In succeeding iterations the search direction is computed 
%      according to the following formula:
% 
%        dX = -H\gX;
% 
%      where gX is the gradient and H is an approximate Hessian matrix.
% 	  See page 119 of Gill, Murray & Wright (Practical Optimization  1981) for
%      a more detailed discussion of the BFGS quasi-Newton method.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function trainbr
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINBR Bayesian Regulation backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = trainbr(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = trainbr(code)
% 
% 	Description
% 
% 	  TRAINBR is a network training function that updates the weight and
% 	  bias values according to Levenberg-Marquardt optimization.  It
%      minimizes a combination of squared errors and weights
%      and, then determines the correct combination so as to produce a
%      network which generalizes well.  The process is called Bayesian
%      regularization.
% 
% 	  TRAINBR(NET,Pd,Tl,Ai,Q,TS,VV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 	          TR.mu - Adaptive mu value.
% 
% 	  Training occurs according to the TRAINLM's training parameters,
% 	  shown here with their default values:
% 	    net.trainParam.epochs     100  Maximum number of epochs to train
% 	    net.trainParam.goal         0  Performance goal
% 	    net.trainParam.mu       0.005  Marquardt adjustment parameter
% 	    net.trainParam.mu_dec     0.1  Decrease factor for mu
% 	    net.trainParam.mu_inc      10  Increase factor for mu
% 	    net.trainParam.mu_max   1e-10  Maximum value for mu
% 	    net.trainParam.max_fail     5  Maximum validation failures
% 	    net.trainParam.mem_reduc    1  Factor to use for memory/speed trade off.
% 	    net.trainParam.min_grad 1e-10  Minimum performance gradient
% 	    net.trainParam.show        25  Epochs between showing progress
% 	    net.trainParam.time       inf  Maximum time to train in seconds
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is normally used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.  This early stopping is not used
%      for TRAINBR, but the validation performance is computed for
%      analysis purposes if VV is not [].
% 
% 	  TRAINBR(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINBR with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINBR:
% 	  1) Set NET.trainFcn to 'trainlm'.
% 	     This will set NET.trainParam to TRAINBR's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINBR.
% 
% 	  See NEWFF, NEWCF, and NEWELM for examples.
% 
%    Example
% 
%      Here is a problem consisting of inputs p and targets t that we would
%      like to solve with a network.  It involves fitting a noisy sine wave.
% 
%        p = [-1:.05:1];
%        t = sin(2*pi*p)+0.1*randn(size(p));
% 
%      Here a two-layer feed-forward network is created.  The network's
%      input ranges from [-1 to 1].  The first layer has 20 TANSIG
%      neurons, and the second layer has one PURELIN neuron.  The TRAINBR
%      network training function is to be used.  The plot of the
%      resulting network output should show a smooth response, without
%      overfitting.
% 
%        % Create a Network
%        net=newff([-1 1],[20,1],{'tansig','purelin'},'trainbr');
% 
%        % Train and Test the Network
%        net.trainParam.epochs = 50;
%        net.trainParam.show = 10;
%        net = train(net,p,t);
%        a = sim(net,p)
%        plot(p,a,p,t,'+')
% 
% 	Algorithm
% 
% 	  TRAINBR can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
%      Bayesian regularization minimizes a linear combination of squared
%      errors and weights.  It also modifies the linear combination
%      so that at the end of training the resulting network has good
%      generalization qualities.
%      See MacKay (Neural Computation, vol. 4, no. 3, 1992, pp. 415-447)
%      and Foresee and Hagan (Proceedings of the International Joint
%      Conference on Neural Networks, June, 1997) for more detailed
%      discussions of Bayesian regularization.
% 
%      This Bayesian regularization takes place within the Levenberg-Marquardt
%      algorithm. Backpropagation is used to calculate the Jacobian jX of
% 	  performance PERF with respect to the weight and bias variables X. 
% 	  Each variable is adjusted according to Levenberg-Marquardt,
% 
% 	    jj = jX * jX
% 	    je = jX * E
% 	    dX = -(jj+I*mu) \ je
% 
% 	  where E is all errors and I is the identity matrix.
% 
% 	  The adaptive value MU is increased by MU_INC until the change shown above
% 	  results in a reduced performance value.  The change is then made to
% 	  the network and mu is decreased by MU_DEC.
% 
% 	  The parameter MEM_REDUC indicates how to use memory and speed to
% 	  calculate the Jacobian jX.  If MEM_REDUC is 1, then TRAINLM runs
% 	  the fastest, but can require a lot of memory. Increasing MEM_REDUC
% 	  to 2 cuts some of the memory required by a factor of two, but
% 	  slows TRAINLM somewhat.  Higher values continue to decrease the
% 	  amount of memory needed and increase the training times.
% 
% 	  Training stops when any of these conditions occur:
% 
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) MU exceeds MU_MAX.
% 	  6) Validation performance has increase more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function traincgb
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINCGB Conjugate gradient backpropagation with Powell-Beale restarts.
% 
% 	Syntax
% 	
% 	  [net,tr] = traincgb(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = traincgb(code)
% 
% 	Description
% 
% 	  TRAINCGB is a network training function that updates weight and
% 	  bias values according to the conjugate gradient backpropagation
%      with Powell-Beale restarts.
% 
% 	TRAINCGB(NET,Pd,Tl,Ai,Q,TS,VV,TV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	    TV  - Either empty matrix [] or structure of test vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINCGB's training parameters,
% 	  shown here with their default values:
% 	    net.trainParam.epochs          100  Maximum number of epochs to train
% 	    net.trainParam.show             25  Epochs between showing progress
% 	    net.trainParam.goal              0  Performance goal
% 	    net.trainParam.time            inf  Maximum time to train in seconds
% 	    net.trainParam.min_grad       1e-6  Minimum performance gradient
% 	    net.trainParam.max_fail          5  Maximum validation failures
%        net.trainParam.searchFcn 'srchcha'  Name of line search routine to use.
% 
%    Parameters related to line search methods (not all used for all methods):
% 	    net.trainParam.scal_tol         20  Divide into delta to determine tolerance for linear search.
% 	    net.trainParam.alpha         0.001  Scale factor which determines sufficient reduction in perf.
% 	    net.trainParam.beta            0.1  Scale factor which determines sufficiently large step size.
% 	    net.trainParam.delta          0.01  Initial step size in interval location step.
% 	    net.trainParam.gama            0.1  Parameter to avoid small reductions in performance. Usually set
%                                            to 0.1. (See use in SRCH_CHA.)
% 	    net.trainParam.low_lim         0.1  Lower limit on change in step size.
% 	    net.trainParam.up_lim          0.5  Upper limit on change in step size.
% 	    net.trainParam.maxstep         100  Maximum step length.
% 	    net.trainParam.minstep      1.0e-6  Minimum step length.
% 	    net.trainParam.bmax             26  Maximum step size.
% 
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  If TV is not [], it must be a structure of validation vectors,
% 	    TV.PD - Validation delayed inputs.
% 	    TV.Tl - Validation layer targets.
% 	    TV.Ai - Validation initial input conditions.
% 	    TV.Q  - Validation batch size.
% 	    TV.TS - Validation time steps.
% 	  which is used to test the generalization capability of the
%      trained network.
% 
% 	  TRAINCGB(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINCGB with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINCGB:
% 	  1) Set NET.trainFcn to 'traincgb'.
% 	     This will set NET.trainParam to TRAINCGB's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINCGB.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINCGB
%      network training function is to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'traincgb');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 	  See NEWFF, NEWCF, and NEWELM for other examples.
% 
% 	Algorithm
% 
% 	  TRAINCGB can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
%      Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to the following:
% 
%        X = X + a*dX;
% 
%      where dX is the search direction.  The parameter a is selected
%      to minimize the performance along the search direction.  The line
%      search function searchFcn is used to locate the minimum point.
%      The first search direction is the negative of the gradient of performance.
%      In succeeding iterations the search direction is computed from the new
%      gradient and the previous search direction according to the
%      formula:
% 
%        dX = -gX + dX_old*Z;
% 
%      where gX is the gradient. The parameter Z can be computed in several 
%      different ways.  The Powell-Beale variation of conjugate gradient
%      is distinguished by two features.  First, the algorithm uses a test
%      to determine when to reset the search direction to the negative of
%      the gradient.  Second, the search direction is computed from the
%      negative gradient, the previous search direction, and the last
%      search direction before the previous reset.
% 	  See Powell, Mathematical Programming, Vol. 12 (1977) pp. 241-254, for
%      a more detailed discussion of the algorithm.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function traincgf
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINCGF Conjugate gradient backpropagation with Fletcher-Reeves updates.
% 
% 	Syntax
% 	
% 	  [net,tr] = traincgf(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = traincgf(code)
% 
% 	Description
% 
% 	  TRAINCGF is a network training function that updates weight and
% 	  bias values according to the conjugate gradient backpropagation
%      with Fletcher-Reeves updates.
% 
% 	TRAINCGF(NET,Pd,Tl,Ai,Q,TS,VV,TV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	    TV  - Either empty matrix [] or structure of test vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINCGF's training parameters,
% 	  shown here with their default values:
% 	    net.trainParam.epochs          100  Maximum number of epochs to train
% 	    net.trainParam.show             25  Epochs between showing progress
% 	    net.trainParam.goal              0  Performance goal
% 	    net.trainParam.time            inf  Maximum time to train in seconds
% 	    net.trainParam.min_grad       1e-6  Minimum performance gradient
% 	    net.trainParam.max_fail          5  Maximum validation failures
%        net.trainParam.searchFcn 'srchcha'  Name of line search routine to use.
% 
%    Parameters related to line search methods (not all used for all methods):
% 	    net.trainParam.scal_tol         20  Divide into delta to determine tolerance for linear search.
% 	    net.trainParam.alpha         0.001  Scale factor which determines sufficient reduction in perf.
% 	    net.trainParam.beta            0.1  Scale factor which determines sufficiently large step size.
% 	    net.trainParam.delta          0.01  Initial step size in interval location step.
% 	    net.trainParam.gama            0.1  Parameter to avoid small reductions in performance. Usually set
%                                            to 0.1. (See use in SRCH_CHA.)
% 	    net.trainParam.low_lim         0.1  Lower limit on change in step size.
% 	    net.trainParam.up_lim          0.5  Upper limit on change in step size.
% 	    net.trainParam.maxstep         100  Maximum step length.
% 	    net.trainParam.minstep      1.0e-6  Minimum step length.
% 	    net.trainParam.bmax             26  Maximum step size.
% 
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  If TV is not [], it must be a structure of validation vectors,
% 	    TV.PD - Validation delayed inputs.
% 	    TV.Tl - Validation layer targets.
% 	    TV.Ai - Validation initial input conditions.
% 	    TV.Q  - Validation batch size.
% 	    TV.TS - Validation time steps.
% 	  which is used to test the generalization capability of the
%      trained network.
% 
% 	  TRAINCGF(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINCGF with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINCGF:
% 	  1) Set NET.trainFcn to 'traincgf'.
% 	     This will set NET.trainParam to TRAINCGF's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINCGF.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINCGF
%      network training function is to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'traincgf');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 	  See NEWFF, NEWCF, and NEWELM for other examples.
% 
% 	Algorithm
% 
% 	  TRAINCGF can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
%      Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to the following:
% 
%        X = X + a*dX;
% 
%      where dX is the search direction.  The parameter a is selected
%      to minimize the performance along the search direction.  The line
%      search function searchFcn is used to locate the minimum point.
%      The first search direction is the negative of the gradient of performance.
%      In succeeding iterations the search direction is computed from the new
%      gradient and the previous search direction, according to the
%      formula:
% 
%        dX = -gX + dX_old*Z;
% 
%      where gX is the gradient. The parameter Z can be computed in several 
%      different ways.  For the Fletcher-Reeves variation of conjugate gradient
%      it is computed according to
% 
%       Z=normnew_sqr/norm_sqr;
% 
%      where norm_sqr is the norm square of the previous gradient and
%      normnew_sqr is the norm square of the current gradient.
% 	  See page 78 of Scales (Introduction to Non-Linear Optimization 1985) for
%      a more detailed discussion of the algorithm.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function traincgp
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINCGP Conjugate gradient backpropagation with Polak-Ribiere updates.
% 
% 	Syntax
% 	
% 	  [net,tr] = traincgp(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = traincgp(code)
% 
% 	Description
% 
% 	  TRAINCGP is a network training function that updates weight and
% 	  bias values according to the conjugate gradient backpropagation
%      with Polak-Ribiere updates.
% 
% 	TRAINCGP(NET,Pd,Tl,Ai,Q,TS,VV,TV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	    TV  - Either empty matrix [] or structure of test vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINCGP's training parameters,
% 	  shown here with their default values:
% 	    net.trainParam.epochs          100  Maximum number of epochs to train
% 	    net.trainParam.show             25  Epochs between showing progress
% 	    net.trainParam.goal              0  Performance goal
% 	    net.trainParam.time            inf  Maximum time to train in seconds
% 	    net.trainParam.min_grad       1e-6  Minimum performance gradient
% 	    net.trainParam.max_fail          5  Maximum validation failures
%        net.trainParam.searchFcn 'srchcha'  Name of line search routine to use.
% 
%    Parameters related to line search methods (not all used for all methods):
% 	    net.trainParam.scal_tol         20  Divide into delta to determine tolerance for linear search.
% 	    net.trainParam.alpha         0.001  Scale factor which determines sufficient reduction in perf.
% 	    net.trainParam.beta            0.1  Scale factor which determines sufficiently large step size.
% 	    net.trainParam.delta          0.01  Initial step size in interval location step.
% 	    net.trainParam.gama            0.1  Parameter to avoid small reductions in performance. Usually set
%                                            to 0.1. (See use in SRCH_CHA.)
% 	    net.trainParam.low_lim         0.1  Lower limit on change in step size.
% 	    net.trainParam.up_lim          0.5  Upper limit on change in step size.
% 	    net.trainParam.maxstep         100  Maximum step length.
% 	    net.trainParam.minstep      1.0e-6  Minimum step length.
% 	    net.trainParam.bmax             26  Maximum step size.
% 
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  If TV is not [], it must be a structure of validation vectors,
% 	    TV.PD - Validation delayed inputs.
% 	    TV.Tl - Validation layer targets.
% 	    TV.Ai - Validation initial input conditions.
% 	    TV.Q  - Validation batch size.
% 	    TV.TS - Validation time steps.
% 	  which is used to test the generalization capability of the
%      trained network.
% 
% 	  TRAINCGP(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINCGP with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINCGP:
% 	  1) Set NET.trainFcn to 'traincgp'.
% 	     This will set NET.trainParam to TRAINCGP's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINCGP.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINCGP
%      network training function is to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'traincgp');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 	  See NEWFF, NEWCF, and NEWELM for other examples.
% 
% 	Algorithm
% 
% 	  TRAINCGP can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
%      Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to the following:
% 
%        X = X + a*dX;
% 
%      where dX is the search direction.  The parameter a is selected
%      to minimize the performance along the search direction.  The line
%      search function searchFcn is used to locate the minimum point.
%      The first search direction is the negative of the gradient of performance.
%      In succeeding iterations the search direction is computed from the new
%      gradient and the previous search direction according to the
%      formula:
% 
%        dX = -gX + dX_old*Z;
% 
%      where gX is the gradient. The parameter Z can be computed in several 
%      different ways.  For the Polak-Ribiere variation of conjugate gradient
%      it is computed according to:
% 
%       Z = ((gX - gX_old)'*gX)/norm_sqr;
% 
%      where norm_sqr is the norm square of the previous gradient and
%      gX_old is the gradient on the previous iteration.
% 	  See page 78 of Scales (Introduction to Non-Linear Optimization 1985) for
%      a more detailed discussion of the algorithm.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function traingd
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINGD Gradient descent backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = traingd(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = traingd(code)
% 
% 	Description
% 
% 	  TRAINGD is a network training function that updates weight and
% 	  bias values according to gradient descent.
% 
% 	  TRAINGD(NET,Pd,Tl,Ai,Q,TS,VV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either an empty matrix [] or a structure of validation vectors.
% 	  and returns:
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf  - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINGD's training parameters
% 	  shown here with their default values:
% 	    net.trainParam.epochs      10  Maximum number of epochs to train
% 	    net.trainParam.goal         0  Performance goal
% 	    net.trainParam.lr        0.01  Learning rate
% 	    net.trainParam.max_fail     5  Maximum validation failures
% 	    net.trainParam.min_grad 1e-10  Minimum performance gradient
% 	    net.trainParam.show        25  Epochs between showing progress
% 	    net.trainParam.time       inf  Maximum time to train in seconds
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which are used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remain the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  TRAINGD(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINGD with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINGD:
% 	  1) Set NET.trainFcn to 'traingd'.
% 	     This will set NET.trainParam to TRAINGD's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINGD.
% 
% 	  See NEWFF, NEWCF, and NEWELM for examples.
% 
% 	Algorithm
% 
% 	  TRAINGD can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
% 	  Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to gradient descent:
% 
% 	    dX = lr * dperf/dX
% 
% 	  Training stops when any of these conditions occurs:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function traingdm
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINGDM Gradient descent with momentum backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = traingdm(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = traingdm(code)
% 
% 	Description
% 
% 	  TRAINGDM is a network training function that updates weight and
% 	  bias values according to gradient descent with momentum.
% 
% 	  TRAINGDM(NET,Pd,Tl,Ai,Q,TS,VV) takes these inputs:
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	  and returns:
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf  - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINGDM's training parameters
% 	  shown here with their default values:
% 	    net.trainParam.epochs      10  Maximum number of epochs to train
% 	    net.trainParam.goal         0  Performance goal
% 	    net.trainParam.lr        0.01  Learning rate
% 	    net.trainParam.max_fail     5  Maximum validation failures
% 	    net.trainParam.mc         0.9  Momentum constant.
% 	    net.trainParam.min_grad 1e-10  Minimum performance gradient
% 	    net.trainParam.show        25  Epochs between showing progress
% 	    net.trainParam.time       inf  Maximum time to train in seconds
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  TRAINGDM(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINGDM with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINGDM:
% 	  1) Set NET.trainFcn to 'traingdm'.
% 	     This will set NET.trainParam to TRAINGDM's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINGDM.
% 
% 	  See NEWFF, NEWCF, and NEWELM for examples.
% 
% 	Algorithm
% 
% 	  TRAINGDM can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
% 	  Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to gradient descent with
% 	  momentum,
% 
% 	    dX = mc*dXprev + lr*mc*dperf/dX
% 
% 	  where dXprev is the previous change to the weight or bias.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increase more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function traingda
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINGDA Gradient descent with adaptive lr backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = traingda(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = traingda(code)
% 
% 	Description
% 
% 	  TRAINGDA is a network training function that updates weight and
% 	  bias values according to gradient descent with adaptive
% 	  learning rate.
% 
% 	  TRAINGDA(NET,Pd,Tl,Ai,Q,TS,VV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf  - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 	          TR.lr    - Adaptive learning rate.
% 
% 	  Training occurs according to the TRAINGDA's training parameters,
% 	  shown here with their default values:
% 	    net.trainParam.epochs         10  Maximum number of epochs to train
% 	    net.trainParam.goal            0  Performance goal
% 	    net.trainParam.lr           0.01  Learning rate
% 	    net.trainParam.lr_inc       1.05  Ratio to increase learning rate
% 	    net.trainParam.lr_dec        0.7  Ratio to decrease learning rate
% 	    net.trainParam.max_fail        5  Maximum validation failures
% 	    net.trainParam.max_perf_inc 1.04  Maximum performance increase
% 	    net.trainParam.min_grad    1e-10  Minimum performance gradient
% 	    net.trainParam.show           25  Epochs between showing progress
% 	    net.trainParam.time          inf  Maximum time to train in seconds
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which are used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  TRAINGDA(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINGDA with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINGDA:
% 	  1) Set NET.trainFcn to 'traingda'.
% 	     This will set NET.trainParam to TRAINGDA's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINGDA.
% 
% 	  See NEWFF, NEWCF, and NEWELM for examples.
% 
% 	Algorithm
% 
% 	  TRAINGDA can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
% 	  Backpropagation is used to calculate derivatives of performance
% 	  DPERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to gradient descent:
% 
% 	    dX = lr*dperf/dX
% 
% 	  Each of epoch, if performance decreases toward the goal, then
% 	  the learning rate is increased by the factor lr_inc.  If
% 	  performance increases by more than the factor max_perf_inc,
% 	  the learning rate is adjusted by the factor lr_dec and the
% 	  change, which increased the performance, is not made.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function traingdx
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINGDX Gradient descent w/momentum & adaptive lr backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = traingdx(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = traingdx(code)
% 
% 	Description
% 
% 	  TRAINGDX is a network training function that updates weight and
% 	  bias values according to gradient descent momentum and an
% 	  adaptive learning rate.
% 
% 	  TRAINGDX(NET,Pd,Tl,Ai,Q,TS,VV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf  - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 	          TR.lr    - Adaptive learning rate.
% 
% 	  Training occurs according to the TRAINGDX's training parameters
% 	  shown here with their default values:
% 	    net.trainParam.epochs         10  Maximum number of epochs to train
% 	    net.trainParam.goal            0  Performance goal
% 	    net.trainParam.lr           0.01  Learning rate
% 	    net.trainParam.lr_inc       1.05  Ratio to increase learning rate
% 	    net.trainParam.lr_dec        0.7  Ratio to decrease learning rate
% 	    net.trainParam.max_fail        5  Maximum validation failures
% 	    net.trainParam.max_perf_inc 1.04  Maximum performance increase
% 	    net.trainParam.mc            0.9  Momentum constant.
% 	    net.trainParam.min_grad    1e-10  Minimum performance gradient
% 	    net.trainParam.show           25  Epochs between showing progress
% 	    net.trainParam.time          inf  Maximum time to train in seconds
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is an VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  TRAINGDX(CODE) return useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINGDX with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINGDX:
% 	  1) Set NET.trainFcn to 'traingdx'.
% 	     This will set NET.trainParam to TRAINGDX's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINGDX.
% 
% 	  See NEWFF, NEWCF, and NEWELM for examples.
% 
% 	Algorithm
% 
% 	  TRAINGDX can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
% 	  Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to the gradient descent
% 	  with momentum.
% 
% 	    dX = mc*dXprev + lr*mc*dperf/dX
% 
% 	  where dXprev is the previous change to the weight or bias.
% 
% 	  For each epoch, if performance decreases toward the goal, then
% 	  the learning rate is increased by the factor lr_inc.  If
% 	  performance increases by more than the factor max_perf_inc,
% 	  the learning rate is adjusted by the factor lr_dec and the
% 	  change, which increased the performance, is not made.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increase more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function trainlm
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINLM Levenberg-Marquardt backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = trainlm(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = trainlm(code)
% 
% 	Description
% 
% 	  TRAINLM is a network training function that updates weight and
% 	  bias values according to Levenberg-Marquardt optimization.
% 
% 	  TRAINLM(NET,Pd,Tl,Ai,Q,TS,VV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf  - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 	          TR.mu    - Adaptive mu value.
% 
% 	  Training occurs according to the TRAINLM's training parameters
% 	  shown here with their default values:
% 	    net.trainParam.epochs      10  Maximum number of epochs to train
% 	    net.trainParam.goal         0  Performance goal
% 	    net.trainParam.lr        0.01  Learning rate
% 	    net.trainParam.max_fail     5  Maximum validation failures
% 	    net.trainParam.mem_reduc    1  Factor to use for memory/speed trade off.
% 	    net.trainParam.min_grad 1e-10  Minimum performance gradient
% 	    net.trainParam.show        25  Epochs between showing progress
% 	    net.trainParam.time       inf  Maximum time to train in seconds
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  TRAINLM(CODE) return useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINLM with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINLM:
% 	  1) Set NET.trainFcn to 'trainlm'.
% 	     This will set NET.trainParam to TRAINLM's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINLM.
% 
% 	  See NEWFF, NEWCF, and NEWELM for examples.
% 
% 	Algorithm
% 
% 	  TRAINLM can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
% 	  Backpropagation is used to calculate the Jacobian jX of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to Levenberg-Marquardt,
% 
% 	    jj = jX * jX
% 	    je = jX * E
% 	    dX = -(jj+I*mu) \ je
% 
% 	  where E is all errors and I is the identity matrix.
% 
% 	  The adaptive value MU is increased by MU_INC until the change above
% 	  results in a reduced performance value.  The change is then made to
% 	  the network and mu is decreased by MU_DEC.
% 
% 	  The parameter MEM_REDUC indicates how to use memory and speed to
% 	  calculate the Jacobian jX.  If MEM_REDUC is 1, then TRAINLM runs
% 	  the fastest, but can require a lot of memory. Increasing MEM_REDUC
% 	  to 2, cuts some of the memory required by a factor of two, but
% 	  slows TRAINLM somewhat.  Higher values continue to decrease the
% 	  amount of memory needed and increase training times.
% 
% 	  Training stops when any of these conditions occurs:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) MU exceeds MU_MAX.
% 	  6) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function trainoss
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINOSS One step secant backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = trainoss(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = trainoss(code)
% 
% 	Description
% 
% 	  TRAINOSS is a network training function that updates weight and
% 	  bias values according to the one step secant method.
% 
% 	TRAINOSS(NET,Pd,Tl,Ai,Q,TS,VV,TV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	    TV  - Either empty matrix [] or structure of test vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINOSS's training parameters,
% 	  shown here with their default values:
% 	    net.trainParam.epochs          100  Maximum number of epochs to train
% 	    net.trainParam.show             25  Epochs between showing progress
% 	    net.trainParam.goal              0  Performance goal
% 	    net.trainParam.time            inf  Maximum time to train in seconds
% 	    net.trainParam.min_grad       1e-6  Minimum performance gradient
% 	    net.trainParam.max_fail          5  Maximum validation failures
%        net.trainParam.searchFcn 'srchcha'  Name of line search routine to use.
% 
%    Parameters related to line search methods (not all used for all methods):
% 	    net.trainParam.scal_tol         20  Divide into delta to determine tolerance for linear search.
% 	    net.trainParam.alpha         0.001  Scale factor which determines sufficient reduction in perf.
% 	    net.trainParam.beta            0.1  Scale factor which determines sufficiently large step size.
% 	    net.trainParam.delta          0.01  Initial step size in interval location step.
% 	    net.trainParam.gama            0.1  Parameter to avoid small reductions in performance. Usually set
%                                            to 0.1. (See use in SRCH_CHA.)
% 	    net.trainParam.low_lim         0.1  Lower limit on change in step size.
% 	    net.trainParam.up_lim          0.5  Upper limit on change in step size.
% 	    net.trainParam.maxstep         100  Maximum step length.
% 	    net.trainParam.minstep      1.0e-6  Minimum step length.
% 	    net.trainParam.bmax             26  Maximum step size.
% 
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  If TV is not [], it must be a structure of validation vectors,
% 	    TV.PD - Validation delayed inputs.
% 	    TV.Tl - Validation layer targets.
% 	    TV.Ai - Validation initial input conditions.
% 	    TV.Q  - Validation batch size.
% 	    TV.TS - Validation time steps.
% 	  which is used to test the generalization capability of the
%      trained network.
% 
% 	  TRAINOSS(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINOSS with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINOSS:
% 	  1) Set NET.trainFcn to 'trainoss'.
% 	     This will set NET.trainParam to TRAINCGP's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINOSS.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINOSS
%      network training function is to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'trainoss');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 	  See NEWFF, NEWCF, and NEWELM for other examples.
% 
% 	Algorithm
% 
% 	  TRAINOSS can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
%      Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to the following:
% 
%        X = X + a*dX;
% 
%      where dX is the search direction.  The parameter a is selected
%      to minimize the performance along the search direction.  The line
%      search function searchFcn is used to locate the minimum point.
%      The first search direction is the negative of the gradient of performance.
%      In succeeding iterations the search direction is computed from the new
%      gradient and the previous steps and gradients according to the following
%      formula:
% 
%        dX = -gX + Ac*X_step + Bc*dgX;
% 
%      where gX is the gradient, X_step is the change in the weights on the
%      previous iteration, and dgX is the change in the gradient from the
%      last iteration. 
%      See Battiti (Neural Computation, vol. 4, 1992, pp. 141-166) for
%      a more detailed discussion of the one step secant algorithm.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function trainrp
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINRP RPROP backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = trainrp(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = trainrp(code)
% 
% 	Description
% 
% 	  TRAINRP is a network training function that updates weight and
% 	  bias values according to the resilient backpropagation algorithm
%      (RPROP).
% 
% 	TRAINRP(NET,Pd,Tl,Ai,Q,TS,VV,TV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	    TV  - Either empty matrix [] or structure of test vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINRP's training parameters
% 	  shown here with their default values:
% 	    net.trainParam.epochs     100  Maximum number of epochs to train
% 	    net.trainParam.show        25  Epochs between showing progress
% 	    net.trainParam.goal         0  Performance goal
% 	    net.trainParam.time       inf  Maximum time to train in seconds
% 	    net.trainParam.min_grad  1e-6  Minimum performance gradient
% 	    net.trainParam.max_fail     5  Maximum validation failures
% 	    net.trainParam.lr        0.01  Learning rate
% 	    net.trainParam.delt_inc   1.2  Increment to weight change
% 	    net.trainParam.delt_dec   0.5  Decrement to weight change
% 	    net.trainParam.delta0    0.07  Initial weight change
% 	    net.trainParam.deltamax  50.0  Maximum weight change
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  If TV is not [], it must be a structure of validation vectors,
% 	    TV.PD - Validation delayed inputs.
% 	    TV.Tl - Validation layer targets.
% 	    TV.Ai - Validation initial input conditions.
% 	    TV.Q  - Validation batch size.
% 	    TV.TS - Validation time steps.
% 	  which is used to test the generalization capability of the
%      trained network.
% 
% 	  TRAINRP(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINRP with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINRP:
% 	  1) Set NET.trainFcn to 'trainrp'.
% 	     This will set NET.trainParam to TRAINRP's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINRP.
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINRP
% 	  network training function is to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'trainrp');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 	  See NEWFF, NEWCF, and NEWELM for other examples.
% 
% 	Algorithm
% 
% 	  TRAINRP can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
% 
% 	  Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.  Each
% 	  variable is adjusted according to the following:
% 
% 	    dX = deltaX.*sign(gX);
% 
%      where the elements of deltaX are all initialized to delta0 and
%      gX is the gradient.  At each iteration the elements of deltaX
%      are modified.  If an element of gX changes sign from one 
%      iteration to the next, then the corresponding element of
%      deltaX is decreased by delta_dec.  If an element of gX 
%      maintains the same sign from one iteration to the next,
%      then the corresponding element of deltaX is increased by
%      delta_inc.  See Reidmiller, Proceedings of the IEEE Int. Conf. 
%       on NN (ICNN) San Francisco, 1993, pp. 586-591.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function trainscg
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINSCG Scaled conjugate gradient backpropagation.
% 
% 	Syntax
% 	
% 	  [net,tr] = trainscg(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = trainscg(code)
% 
% 	Description
% 
% 	  TRAINSCG is a network training function that updates weight and
% 	  bias values according to the scaled conjugate gradient method.
% 
% 	TRAINSCG(NET,Pd,Tl,Ai,Q,TS,VV,TV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed input vectors.
% 	    Tl  - Layer target vectors.
% 	    Ai  - Initial input delay conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	    TV  - Either empty matrix [] or structure of test vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINSCG's training parameters
% 	  shown here with their default values:
% 	    net.trainParam.epochs          100  Maximum number of epochs to train
% 	    net.trainParam.show             25  Epochs between showing progress
% 	    net.trainParam.goal              0  Performance goal
% 	    net.trainParam.time            inf  Maximum time to train in seconds
% 	    net.trainParam.min_grad       1e-6  Minimum performance gradient
% 	    net.trainParam.max_fail          5  Maximum validation failures
% 	    net.trainParam.sigma        5.0e-5  Determines change in weight for second derivative approximation.
% 	    net.trainParam.lambda       5.0e-7  Parameter for regulating the indefiniteness of the Hessian.
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element P{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.PD - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  If TV is not [], it must be a structure of validation vectors,
% 	    TV.PD - Validation delayed inputs.
% 	    TV.Tl - Validation layer targets.
% 	    TV.Ai - Validation initial input conditions.
% 	    TV.Q  - Validation batch size.
% 	    TV.TS - Validation time steps.
% 	  which is used to test the generalization capability of the
%      trained network.
% 
% 	  TRAINSCG(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINSCG with
% 	  NEWFF, NEWCF, or NEWELM.
% 
% 	  To prepare a custom network to be trained with TRAINSCG:
% 	  1) Set NET.trainFcn to 'trainscg'.
% 	     This will set NET.trainParam to TRAINSCG's default parameters.
% 	  2) Set NET.trainParam properties to desired values.
% 
% 	  In either case, calling TRAIN with the resulting network will
% 	  train the network with TRAINSCG.
% 
% 
% 	Examples
% 
% 	  Here is a problem consisting of inputs P and targets T that we would
% 	  like to solve with a network.
% 
% 	    P = [0 1 2 3 4 5];
% 	    T = [0 0 0 1 1 1];
% 
% 	  Here a two-layer feed-forward network is created.  The network's
% 	  input ranges from [0 to 10].  The first layer has two TANSIG
% 	  neurons, and the second layer has one LOGSIG neuron.  The TRAINSCG
%      network training function is to be used.
% 
% 	    % Create and Test a Network
% 	    net = newff([0 5],[2 1],{'tansig','logsig'},'trainscg');
% 	    a = sim(net,p)
% 
% 	    % Train and Retest the Network
% 	    net.trainParam.epochs = 50;
% 	    net.trainParam.show = 10;
% 	    net.trainParam.goal = 0.1;
% 	    net = train(net,p,t);
% 	    a = sim(net,p)
% 
% 	  See NEWFF, NEWCF, and NEWELM for other examples.
% 
% 	Algorithm
% 
% 	  TRAINSCG can train any network as long as its weight, net input,
% 	  and transfer functions have derivative functions.
%      Backpropagation is used to calculate derivatives of performance
% 	  PERF with respect to the weight and bias variables X.
% 
% 	  The scaled conjugate gradient algorithm is based on conjugate 
%      directions, as in TRAINCGP, TRAINCGF and TRAINCGB, but this 
%      algorithm does not perform a line search at each iteration.
% 	  See Moller (Neural Networks, vol. 6, 1993, pp. 525-533) for a more
%      detailed discussion of the scaled conjugate gradient algorithm.
% 
% 	  Training stops when any of these conditions occur:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 	  3) Performance has been minimized to the GOAL.
% 	  4) The performance gradient falls below MINGRAD.
% 	  5) Validation performance has increased more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function trainwb
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINWB By-weight-and-bias network training function.
% 
% 	Syntax
% 	
% 	  [net,tr] = trainwb(net,Pd,Tl,Ai,Q,TS,VV)
% 	  info = trainwb(code)
% 
% 	Description
% 
% 	  TRAINWB is a network training function which updates each
% 	  weight and bias according to its learning function.
% 
% 	  TRAINWB(NET,Pd,Tl,Ai,Q,TS,VV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed inputs.
% 	    Tl  - Layer targets.
% 	    Ai  - Initial input conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Either empty matrix [] or structure of validation vectors.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf  - Training performance.
% 	          TR.vperf - Validation performance.
% 	          TR.tperf - Test performance.
% 
% 	  Training occurs according to the TRAINWB's training parameters,
% 	  shown here with their default values:
% 	    net.trainParam.epochs  100  Maximum number of epochs to train
% 	    net.trainParam.goal      0  Performance goal
% 	    net.trainParam.max_fail  5  Maximum validation failures
% 	    net.trainParam.show     25  Epochs between showing progress
% 	    net.trainParam.time    inf  Maximum time to train in seconds
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element Pd{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix or [].
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  If VV is not [], it must be a structure of validation vectors,
% 	    VV.Pd - Validation delayed inputs.
% 	    VV.Tl - Validation layer targets.
% 	    VV.Ai - Validation initial input conditions.
% 	    VV.Q  - Validation batch size.
% 	    VV.TS - Validation time steps.
% 	  which is used to stop training early if the network performance
% 	  on the validation vectors fails to improve or remains the same
% 	  for MAX_FAIL epochs in a row.
% 
% 	  TRAINWB(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINWB by calling
% 	  NEWP or NEWLIN.
% 
% 	  To prepare a custom network to be trained with TRAINWB:
% 	  1) Set NET.trainFcn to 'trainwb'.
% 	     (This will set NET.trainParam to TRAINWB's default parameters.)
% 	  2) Set each NET.inputWeights{i,j}.learnFcn to a learning function.
% 	     Set each NET.layerWeights{i,j}.learnFcn to a learning function.
% 	     Set each NET.biases{i}.learnFcn to a learning function.
% 	     (Weight and bias learning parameters will automatically be
% 	     set to default values for the given learning function.)
% 
% 	  To train the network:
% 	  1) Set NET.trainParam properties to desired values.
% 	  2) Set weight and bias learning parameters to desired values.
% 	  3) Call TRAIN.
% 
% 	  See NEWP and NEWLIN for training examples.
% 
% 	Algorithm
% 
% 	  Each weight and bias updates according to its learning function
% 	  after each epoch (one pass through the entire set of input vectors).
% 
% 	  Training stops when any of these conditions are met:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) Performance has been minimized to the GOAL.
% 	  3) The maximum amount of TIME has been exceeded.
% 	  4) Validation performance has increase more than MAX_FAIL times
% 	     since the last time it decreased (when using validation).
% 
% 	

function trainwb1
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRAINWB1 By-weight-&-bias 1-vector-at-a-time training function.
% 
% 	Syntax
% 	
% 	  [net,tr] = trainwb1(net,Pd,Tl,Ai,Q,TS,VV,TV)
% 	  info = trainwb1(code)
% 
% 	Description
% 
% 	  TRAINWB1 is a network training function which updates each weight
% 	  and bias according to its learning function.  Each epoch, TRAINWB1
% 	  randomly chooses just one input vector (or sequence) to present
% 	  to the network.
% 
% 	  TRAINWB1(NET,Pd,Tl,Ai,Q,TS,VV) takes these inputs,
% 	    NET - Neural network.
% 	    Pd  - Delayed inputs.
% 	    Tl  - Layer targets.
% 	    Ai  - Initial input conditions.
% 	    Q   - Batch size.
% 	    TS  - Time steps.
% 	    VV  - Ignored.
% 	    TV  - Ignored.
% 	  and returns,
% 	    NET - Trained network.
% 	    TR  - Training record of various values over each epoch:
% 	          TR.epoch - Epoch number.
% 	          TR.perf  - Training performance.
% 	          TR.index - Index of presented input vector (or sequence).
% 
% 	  Training occurs according to the TRAINWB's training parameters
% 	  shown here with their default values:
% 	    net.trainParam.epochs  100  Maximum number of epochs to train
% 	    net.trainParam.show     25  Epochs between showing progress
% 	    net.trainParam.time    inf  Maximum time to train in seconds
% 
% 	  Dimensions for these variables are:
% 	    Pd - NoxNixTS cell array, each element Pd{i,j,ts} is a DijxQ matrix.
% 	    Tl - NlxTS cell array, each element P{i,ts} is a VixQ matrix or [].
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 	  Where
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 		LD = net.numLayerDelays
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Vi = net.targets{i}.size
% 	    Dij = Ri * length(net.inputWeights{i,j}.delays)
% 
% 	  TRAINWB1 does not implement validation or test vectors, so arguments
% 	  VV and TV are ignored.
% 
% 	  TRAINWB1(CODE) returns useful information for each CODE string:
% 	    'pnames'    - Names of training parameters.
% 	    'pdefaults' - Default training parameters.
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TRAINWB1 by calling
% 	  NEWC or NEWSOM.
% 
% 	  To prepare a custom network to be trained with TRAINWB1:
% 	  1) Set NET.trainFcn to 'trainwb1'.
% 	     (This will set NET.trainParam to TRAINWB1's default parameters.)
% 	  2) Set each NET.inputWeights{i,j}.learnFcn to a learning function.
% 	     Set each NET.layerWeights{i,j}.learnFcn to a learning function.
% 	     Set each NET.biases{i}.learnFcn to a learning function.
% 	     (Weight and bias learning parameters will automatically be
% 	     set to default values for the given learning function.)
% 
% 	  To train the network:
% 	  1) Set NET.trainParam properties to desired values.
% 	  2) Set weight and bias learning parameters to desired values.
% 	  3) Call TRAIN.
% 
% 	  See NEWC and NEWSOM for training examples.
% 
% 	Algorithm
% 
% 	  For each epoch, a vector (or sequence) is chosen randomly and
% 	  presented to the network and weight and bias values are
% 	  updated accordingly.
% 
% 	  Training stops when any of these conditions are met:
% 	  1) The maximum number of EPOCHS (repetitions) is reached.
% 	  2) The maximum amount of TIME has been exceeded.
% 
% 	

function compet
%MATLAB Tour Partial Function Help:  nnt_con
%
% COMPET Competitive transfer function.
% 	
% 	Syntax
% 
% 	  A = compet(N)
% 	  info = compet(code)
% 
% 	Description
% 	
% 	  COMPET is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  COMPET(N) takes one input argument,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns output vectors with 1 where each net input
% 	  vector has its maximum value, and 0 elsewhere.
% 	
% 	  COMPET(code) returns information about this function.
% 	  These codes are defined:
% 	    'deriv'  - Name of derivative function.
% 	    'name'   - Full name.
% 	    'output' - Output range.
% 	    'active' - Active input range.
% 
% 	  COMPET does not have a derivative function.
% 	
% 	Examples
% 
% 	  Here we define a net input vector N, calculate the output,
% 	  and plot both with bar graphs.
% 
% 	    n = [0; 1; -0.5; 0.5];
% 	    a = compet(n);
% 	    subplot(2,1,1), bar(n), ylabel('n')
% 	    subplot(2,1,2), bar(a), ylabel('a')
% 
% 	Network Use
% 
% 	  You can create a standard network that uses COMPET
% 	  by calling NEWC or NEWPNN.
% 
% 	  To change a network so a layer uses COMPET set
% 	  NET.layers{i,j}.transferFcn to 'compet'.
% 
% 	  In either case, call SIM to simulate the network with COMPET.
% 	  See NEWC or NEWPNN for simulation examples.
% 
% 	

function hardlim
%MATLAB Tour Partial Function Help:  nnt_con
%
% HARDLIM Hard limit transfer function.
% 	
% 	Syntax
% 
% 	  A = hardlim(N)
% 	  info = hardlim(code)
% 
% 	Description
% 	
% 	  HARDLIM is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  HARDLIM(N) takes one input,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns 1 where N is positive, 0 elsewhere.
% 	
% 	  HARDLIM(CODE) returns useful information for each CODE string:
% 	    'deriv'  - Name of derivative function.
% 	    'name'   - Full name.
% 	    'output' - Output range.
% 	    'active' - Active input range.
% 	
% 	Examples
% 
% 	  Here is how to create a plot of the HARDLIM transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = hardlim(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses HARDLIM
% 	  by calling NEWP.
% 
% 	  To change a network so that a layer uses HARDLIM set
% 	  NET.layers{i}.transferFcn to 'hardlim'.
% 
% 	  In either case, call SIM to simulate the network with HARDLIM.
% 	  See NEWP for simulation examples.
% 
% 	Algorithm
% 
% 	    hardlim(n) = 1, if n >= 0
% 	                 0, otherwise
% 
% 	

function hardlims
%MATLAB Tour Partial Function Help:  nnt_con
%
% HARDLIMS Symmetric hard limit transfer function.
% 	
% 	Syntax
% 
% 	  A = hardlims(N)
% 	  info = hardlims(code)
% 
% 	Description
% 	
% 	  HARDLIMS is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  HARDLIMS(N) takes one input,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns 1 where N is positive, -1 elsewhere.
% 	
% 	  HARDLIMS(CODE) returns useful information for each CODE string:
% 	    'deriv'  - Name of derivative function.
% 	    'name'   - Full name.
% 	    'output' - Output range.
% 	    'active' - Active input range.
% 	
% 	Examples
% 
% 	  Here is how to create a plot of the HARDLIMS transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = hardlims(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses HARDLIMS
% 	  by calling NEWP.
% 
% 	  To change a network so that a layer uses HARDLIMS set
% 	  NET.layers{i}.transferFcn to 'hardlims'.
% 
% 	  In either case, call SIM to simulate the network with HARDLIMS.
% 	  See NEWP for simulation examples.
% 
% 	Algorithm
% 
% 	    hardlims(n) = 1, if n >= 0
% 	                 -1, otherwise
% 
% 	

function logsig
%MATLAB Tour Partial Function Help:  nnt_con
%
% LOGSIG Log sigmoid transfer function.
% 	
% 	Syntax
% 
% 	  A = logsig(N)
% 	  info = logsig(code)
% 
% 	Description
% 	
% 	  LOGSIG is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  LOGSIG(N) takes one input,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns each element of N squashed between 0 and 1.
% 	
% 	  LOGSIG(CODE) returns useful information for each CODE string:
% 	    'deriv'  - Returns name of derivative function.
% 	    'name'   - Returns full name.
% 	    'output' - Returns output range.
% 	    'active' - Returns active input range.
% 	
% 	Examples
% 
% 	  Here is code for creating a plot of the LOGSIG transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = logsig(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses LOGSIG
% 	  by calling NEWFF or NEWCF.
% 
% 	  To change a network so a layer uses LOGSIG set
% 	  NET.layers{i}.transferFcn to 'logsig'.
% 
% 	  In either case, call SIM to simulate the network with PURELIN.
% 	  See NEWFF or NEWCF for simulation examples.
% 
% 	Algorithm
% 
% 	    logsig(n) = 1 / (1 + exp(-n))
% 
% 	

function poslin
%MATLAB Tour Partial Function Help:  nnt_con
%
% POSLIN Positive linear transfer function.
% 	
% 	Syntax
% 
% 	  A = poslin(N)
% 	  info = poslin(code)
% 
% 	Description
% 	
% 	  POSLIN is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  POSLIN(N) takes one input,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns the maximum of 0 and each element of N.
% 	
% 	  POSLIN(CODE) returns useful information for each CODE string:
% 	    'deriv'  - Returns name of derivative function.
% 	    'name'   - Returns full name.
% 	    'output' - Returns output range.
% 	    'active' - Returns active input range.
% 	
% 	Examples
% 
% 	  Here the code to create a plot of the POSLIN transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = poslin(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  To change a network so a layer uses POSLIN set
% 	  NET.layers{i}.transferFcn to 'poslin'.
% 
% 	  Call SIM to simulate the network with POSLIN.
% 
% 	Algorithm
% 
% 	    poslin(n) = n, if n >= 0
% 	              = 0, if n <= 0
% 
% 	

function purelin
%MATLAB Tour Partial Function Help:  nnt_con
%
% PURELIN Linear transfer function.
% 	
% 	Syntax
% 
% 	  A = purelin(N)
% 	  info = purelin(code)
% 
% 	Description
% 	
% 	  PURELIN is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  PURELIN(N) takes one input,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns N.
% 	
% 	  PURELIN(CODE) returns useful information for each CODE string:
% 	    'deriv'  - Returns name of derivative function.
% 	    'name'   - Returns full name.
% 	    'output' - Returns output range.
% 	    'active' - Returns active input range.
% 	
% 	Examples
% 
% 	  Here is the code to create a plot of the PURELIN transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = purelin(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses PURELIN
% 	  by calling NEWLIN or NEWLIND.
% 
% 	  To change a network so a layer uses PURELIN, set
% 	  NET.layers{i}.transferFcn to 'purelin'.
% 
% 	  In either case, call SIM to simulate the network with PURELIN.
% 	  See NEWLIN or NEWLIND for simulation examples.
% 
% 	Algorithm
% 
% 	    purelin(n) = n
% 
% 	

function radbas
%MATLAB Tour Partial Function Help:  nnt_con
%
% RADBAS Radial basis transfer function.
% 	
% 	Syntax
% 
% 	  A = radbas(N)
% 	  info = radbas(code)
% 
% 	Description
% 	
% 	  RADBAS is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  RADBAS(N) takes one input,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns each element of N passed through a
% 	  radial basis function.
% 	
% 	  RADBAS(CODE) returns useful information for each CODE string:
% 	    'deriv'  - Returns name of derivative function.
% 	    'name'   - Returns full name.
% 	    'output' - Returns output range.
% 	    'active' - Returns active input range.
% 	
% 	Examples
% 
% 	  Here we create a plot of the RADBAS transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = radbas(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses RADBAS
% 	  by calling NEWPNN or NEWGRNN.
% 
% 	  To change a network so that a layer uses RADBAS set
% 	  NET.layers{i}.transferFcn to 'radbas'.
% 
% 	  In either case, call SIM to simulate the network with RADBAS.
% 	  See NEWPNN or NEWGRNN for simulation examples.
% 
% 	Algorithm
% 
% 	  RADBAS(N) calculates its output with according to:
% 
% 	    a = exp(-n^2)
% 
% 	

function satlin
%MATLAB Tour Partial Function Help:  nnt_con
%
% SATLIN Saturating linear transfer function.
% 	
% 	Syntax
% 
% 	  A = satlin(N)
% 	  info = satlin(code)
% 
% 	Description
% 	
% 	  SATLIN is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  SATLIN(N)  takes one input,
% 	    N - SxQ Matrix of net input (column) vectors.
% 	  and returns values of N truncated into the interval [-1, 1].
% 	
% 	
% 	  SATLIN(CODE) return useful information for each CODE string:
% 	    'deriv'  - Returns name of derivative function.
% 	    'name'   - Returns full name.
% 	    'output' - Returns output range.
% 	    'active' - Returns active input range.
% 	
% 	Examples
% 
% 	  Here is the code to create a plot of the SATLIN transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = satlin(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  To change a network so that a layer uses SATLIN, set
% 	  NET.layers{i}.transferFcn to 'satlin'.
% 
% 	  Call SIM to simulate the network with SATLIN.
% 	  See NEWHOP for simulation examples.
% 
% 	Algorithm
% 
% 	    satlin(n) = 0, if n <= 0
% 	                n, if 0 <= n <= 1
% 	                1, if 1 <= n
% 
% 	

function satlins
%MATLAB Tour Partial Function Help:  nnt_con
%
% SATLINS Symmetric saturating linear transfer function.
% 	
% 	Syntax
% 
% 	  A = satlins(N)
% 	  info = satlins(code)
% 
% 	Description
% 	
% 	  SATLINS is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  SATLINS(N)  takes one input,
% 	    N - SxQ Matrix of net input (column) vectors.
% 	  and returns values of N truncated into the interval [-1, 1].
% 	
% 	
% 	  SATLINS(CODE) returns useful information for each CODE string:
% 	    'deriv'  - Returns name of derivative function.
% 	    'name'   - Returns full name.
% 	    'output' - Returns output range.
% 	    'active' - Returns active input range.
% 	
% 	Examples
% 
% 	  Here is the code to create a plot of the SATLINS transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = satlins(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses SATLINS
% 	  by calling NEWHOP.
% 
% 	  To change a network so that a layer uses SATLINS, set
% 	  NET.layers{i}.transferFcn to 'satlins'.
% 
% 	  In either case, call SIM to simulate the network with SATLINS.
% 	  See NEWHOP for simulation examples.
% 
% 	Algorithm
% 
% 	    satlins(n) = -1, if n <= -1
% 	                  n, if -1 <= n <= 1
% 	                  1, if 1 <= n
% 
% 	

function softmax
%MATLAB Tour Partial Function Help:  nnt_con
%
% SOFTMAX Soft max transfer function.
% 	
% 	Syntax
% 
% 	  A = softmax(N)
% 	  info = softmax(code)
% 
% 	Description
% 	
% 	  SOFTMAX is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  SOFTMAX(N) takes one input argument,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns output vectors with elements between 0 and 1,
% 	  but with their size relations intact.
% 	
% 	  SOFTMAX('code') returns information about this function.
% 	  These codes are defined:
% 	    'deriv'  - Returns name of derivative function.
% 	    'name'   - Returns full name.
% 	    'output' - Returns output range.
% 	    'active' - Returns active input range.
% 
% 	  COMPET does not have a derivative function.
% 	
% 	Examples
% 
% 	  Here we define a net input vector N, calculate the output,
% 	  and plot both with bar graphs.
% 
% 	    n = [0; 1; -0.5; 0.5];
% 	    a = softmax(n);
% 	    subplot(2,1,1), bar(n), ylabel('n')
% 	    subplot(2,1,2), bar(a), ylabel('a')
% 
% 	Network Use
% 
% 	  To change a network so that a layer uses SOFTMAX, set
% 	  NET.layers{i,j}.transferFcn to 'softmax'.
% 
% 	  Call SIM to simulate the network with SOFTMAX.
% 	  See NEWC or NEWPNN for simulation examples.
% 
% 	

function tansig
%MATLAB Tour Partial Function Help:  nnt_con
%
% TANSIG Hyperbolic tangent sigmoid transfer function.
% 	
% 	Syntax
% 
% 	  A = tansig(N)
% 	  info = tansig(code)
% 
% 	Description
% 	
% 	  TANSIG is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  TANSIG(N) takes one input,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns each element of N squashed between -1 and 1.
% 	
% 	  TANSIG(CODE) returns useful information for each CODE string:
% 	    'deriv'  - Returns name of derivative function.
% 	    'name'   - Returns full name.
% 	    'output' - Returns output range.
% 	    'active' - Returns active input range.
% 
% 	  TANSIG is named after the hyperbolic tangent which has the
% 	  same shape.  However, TANH may be more accurate and is
% 	  recommended for applications that require the hyperbolic tangent.
% 	
% 	Examples
% 
% 	  Here the code to create a plot of the TANSIG transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = tansig(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses TANSIG
% 	  by calling NEWFF or NEWCF.
% 
% 	  To change a network so a layer uses TANSIG set
% 	  NET.layers{i,j}.transferFcn to 'tansig'.
% 
% 	  In either case, call SIM to simulate the network with TANSIG.
% 	  See NEWFF or NEWCF for simulation examples.
% 
% 	Algorithm
% 
% 	  TANSIG(N) calculates its output according to:
% 
% 	    n = 2/(1+exp(-2*n))-1
% 
% 	  This is mathematically equivalent to TANH(N).  It differs
% 	  in that it runs faster than the MATLAB implementation of TANH,
% 	  but the results can have very small numerical differences.  This
% 	  function is a good trade off for neural networks, where speed is
% 	  important and the exact shape of the transfer function is not.
% 
% 	

function tribas
%MATLAB Tour Partial Function Help:  nnt_con
%
% TRIBAS Triangular basis transfer function.
% 	
% 	Syntax
% 
% 	  A = tribas(N)
% 	  info = tribas(code)
% 
% 	Description
% 	
% 	  TRIBAS is a transfer function.  Transfer functions
% 	  calculate a layer's output from its net input.
% 	
% 	  TRIBAS(N) takes one input,
% 	    N - SxQ matrix of net input (column) vectors.
% 	  and returns each element of N passed through a
% 	  radial basis function.
% 	
% 	  TRIBAS(CODE) returns useful information for each CODE string:
% 	    'deriv'  - Returns name of derivative function.
% 	    'name'   - Returns full name.
% 	    'output' - Returns output range.
% 	    'active' - Returns active input range.
% 	
% 	Examples
% 
% 	  Here we create a plot of the TRIBAS transfer function.
% 	
% 	    n = -5:0.1:5;
% 	    a = tribas(n);
% 	    plot(n,a)
% 
% 	Network Use
% 
% 	  To change a network so that a layer uses TRIBAS, set
% 	  NET.layers{i}.transferFcn to 'tribas'.
% 
% 	  Call SIM to simulate the network with TRIBAS.
% 
% 	Algorithm
% 
% 	  TRIBAS(N) calculates its output with according to:
% 
% 	    tribas(n) = 1 - abs(n), if -1 <= n <= 1
%                  = 0, otherwise
% 
% 	

function dhardlim
%MATLAB Tour Partial Function Help:  nnt_con
%
% DHARDLIM Derivative of hard limit transfer function.
% 
% 	Syntax
% 
% 	  dA_dN = dhardlim(N,A)
% 
% 	Description
% 
% 	  DHARDLIM is the derivative function for HARDLIM.
% 
% 	  DHARDLIM(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 HARDLIM
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with HARDLIM and then
% 	  the derivative of A with respect to N.
% 
% 	    A = hardlim(N)
% 	    dA_dN = dhardlim(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of HARDLIM is calculated as follows:
% 
% 	    d = 0
% 
% 	

function dhardlms
%MATLAB Tour Partial Function Help:  nnt_con
%
% DHARDLMS Derivative of symmetric hard limit transfer function.
% 
% 	Syntax
% 
% 	  dA_dN = dhardlms(N,A)
% 
% 	Description
% 
% 	  DHARDLMS is the derivative function for HARDLIMS.
% 
% 	  DHARDLMS(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 HARDLIMS
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with HARDLIMS and then
% 	  the derivative of A with respect to N.
% 
% 	    A = hardlims(N)
% 	    dA_dN = dhardlms(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of HARDLIMS is calculated as follows:
% 
% 	    d = 0
% 
% 	

function dlogsig
%MATLAB Tour Partial Function Help:  nnt_con
%
% DLOGSIG Log sigmoid transfer derivative function.
% 
% 	Syntax
% 
% 	  dA_dN = dlogsig(N,A)
% 
% 	Description
% 
% 	  DLOGSIG is the derivative function for LOGSIG.
% 
% 	  DLOGSIG(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 TANSIG
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with LOGSIG and then
% 	  the derivative of A with respect to N.
% 
% 	    A = logsig(N)
% 	    dA_dN = dlogsig(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of LOGSIG is calculated as follows:
% 
% 	    d = a * (1 - a)
% 
% 	

function dposlin
%MATLAB Tour Partial Function Help:  nnt_con
%
% DPOSLIN Derivative of positive linear transfer function.
% 
% 	Syntax
% 
% 	  dA_dN = dposlin(N,A)
% 
% 	Description
% 
% 	  DPOSLIN is the derivative function for POSLIN.
% 
% 	  DPOSLIN(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 POSLIN
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with POSLIN and then
% 	  the derivative of A with respect to N.
% 
% 	    A = poslin(N)
% 	    dA_dN = dposlin(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of POSLIN is calculated as follows:
% 
% 	    d = 1, if 0 <= n
% 	        0, otherwise
% 
% 	

function dpurelin
%MATLAB Tour Partial Function Help:  nnt_con
%
% DPURELIN Linear transfer derivative function.
% 
% 	Syntax
% 
% 	  dA_dN = dpurelin(N,A)
% 
% 	Description
% 
% 	  DPURELIN is the derivative function for LOGSIG.
% 
% 	  DPURELIN(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 PURELIN
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with PURELIN and then
% 	  the derivative of A with respect to N.
% 
% 	    A = purelin(N)
% 	    dA_dN = dpurelin(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of PURELIN is calculated as follows:
% 
% 	    D(i,q) = 1
% 
% 	

function dradbas
%MATLAB Tour Partial Function Help:  nnt_con
%
% DRADBAS Derivative of radial basis transfer function.
% 
% 	Syntax
% 
% 	  dA_dN = dradbas(N,A)
% 
% 	Description
% 
% 	  DRADBAS is the derivative function for RADBAS.
% 
% 	  DRADBAS(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 RADBAS
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with RADBAS and then
% 	  the derivative of A with respect to N.
% 
% 	    A = radbas(N)
% 	    dA_dN = dradbas(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of RADBAS is calculated as follows:
% 
% 	    d = -2*n*a
% 
% 	

function dsatlin
%MATLAB Tour Partial Function Help:  nnt_con
%
% DSATLIN Derivative of saturating linear transfer function.
% 
% 	Syntax
% 
% 	  dA_dN = dsatlin(N,A)
% 
% 	Description
% 
% 	  DSATLIN is the derivative function for SATLIN.
% 
% 	  DSATLIN(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 SATLIN
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with SATLIN and then
% 	  the derivative of A with respect to N.
% 
% 	    A = satlin(N)
% 	    dA_dN = dsatlin(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of SATLIN is calculated as follows:
% 
% 	    d = 1, if 0 <= n <= 1
% 	        0, otherwise
% 
% 	

function dsatlins
%MATLAB Tour Partial Function Help:  nnt_con
%
% DSATLINS Derivative of symmetric saturating linear transfer function.
% 
% 	Syntax
% 
% 	  dA_dN = dsatlins(N,A)
% 
% 	Description
% 
% 	  DSATLINS is the derivative function for SATLINS.
% 
% 	  DSATLINS(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 SATLINS
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with SATLINS and then
% 	  the derivative of A with respect to N.
% 
% 	    A = satlins(N)
% 	    dA_dN = dsatlins(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of SATLINS is calculated as follows:
% 
% 	    d = 1, if -1 <= n <= 1
% 	        0, otherwise
% 
% 	

function dtansig
%MATLAB Tour Partial Function Help:  nnt_con
%
% DTANSIG Hyperbolic tangent sigmoid transfer derivative function.
% 
% 	Syntax
% 
% 	  dA_dN = dtansig(N,A)
% 
% 	Description
% 
% 	  DTANSIG is the derivative function for TANSIG.
% 
% 	  DTANSIG(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 TANSIG
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with TANSIG and then
% 	  the derivative of A with respect to N.
% 
% 	    A = tansig(N)
% 	    dA_dN = dtansig(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of TANSIG is calculated as follows:
% 
% 	    d = 1-a^2
% 
% 	

function dtribas
%MATLAB Tour Partial Function Help:  nnt_con
%
% DTRIBAS Derivative of triangular basis transfer function.
% 
% 	Syntax
% 
% 	  dA_dN = dtribas(N,A)
% 
% 	Description
% 
% 	  DTRIBAS is the derivative function for TRIBAS.
% 
% 	  DTRIBAS(N,A) takes two arguments,
% 	    N - SxQ net input.
% 	    A - SxQ output.
% 	  and returns the SxQ derivative dA/dN.
% 
% 	Examples
% 
% 	  Here we define the net input N for a layer of 3 TRIBAS
% 	  neurons.
% 
% 	    N = [0.1; 0.8; -0.7];
% 
% 	  We calculate the layer's output A with TRIBAS and then
% 	  the derivative of A with respect to N.
% 
% 	    A = tribas(N)
% 	    dA_dN = dtribas(N,A)
% 
% 	Algorithm
% 
% 	  The derivative of TRIBAS is calculated as follows:
% 
% 	    d = 1, if -1 <= n < 0
% 	       -1, if 0 < n <= 1
% 	        0, otherwise
% 
% 	

function nnt2c
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNT2C Update NNT 2.0 competitive layer to NNT 3.0.
% 
% 	Syntax
% 
% 	  net = nnt2c(pr,w,klr,clr)
% 
% 	Description
% 
% 	  NNT2C(PR,W,KLR,CLR) takes these arguments,
% 	    PR  - Rx2 matrix of min and max values for R input elements.
% 	    W   - SxR weight matrix.
% 	    KLR - Kohonen learning rate, default = 0.01.
% 	    CLR - Conscience learning rate, default = 0.001.
% 	  and returns a competitive layer.
% 
% 	  Once a network has been updated it can be simulated, initialized
% 	  adapted, or trained with SIM, INIT, ADAPT, and TRAIN.
% 	  
% 	

function nnt2elm
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNT2ELM Update NNT 2.0 Elman backpropagation network to NNT 3.0.
% 
% 	Syntax
% 
% 	  net = nnt2elm(pr,w1,b1,w2,b2,btf,blf,pf)
% 
% 	Description
% 
% 	  NNT2ELM(PR,W1,B1,W2,B2,BTF,BLF,PF) takes these arguments,
% 	    PR - Rx2 matrix of min and max values for R input elements.
% 	    W1 - S1x(R+S1) weight matrix.
% 	    B1 - S1x1 bias vector.
% 	    W2 - S2xS1 weight matrix.
% 	    B2 - S2x1 bias vector.
% 	    BTF - Backprop network training function, default = 'traingdx'.
% 	    BLF - Backprop weight/bias learning function, default = 'learngdm'.
% 	    PF  - Performance function, default = 'mse'.
% 	  and returns a feed-forward network.
% 
% 	  The training function BTF can be any of the backprop training
% 	  functions such as TRAINGD, TRAINGDM, TRAINGDA, and TRAINGDX.
% 	  Large step-size algorithms such as TRAINLM are not recommended
% 	  for Elman networks.
% 
% 	  The learning function BLF can be either of the backpropagation
% 	  learning functions such as LEARNGD, or LEARNGDM.
% 
% 	  The performance function can be any of the differentiable performance
% 	  functions such as MSE or MSEREG.
% 
% 	  Once a network has been updated it can be simulated,
% 	  initialized, adapted, or trained with SIM, INIT, ADAPT, and TRAIN.
% 
% 	

function nnt2ff
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNT2FF Update NNT 2.0 feed-forward network to NNT 3.0.
% 
% 	Syntax
% 
% 	  net = nnt2ff(pr,{w1 w2 ...},{b1 b2 ...},{tf1 tf2 ...},btf,blr,pf)
% 
% 	Description
% 
% 	  NNT2FF(PR,{W1 W2 ...},{B1 B2 ...},{TF1 TF2 ...},BTF,BLR,PF) takes these arguments,
% 	    PR - Rx2 matrix of min and max values for R input elements.
% 	    Wi  - Weight matrix for the ith layer.
% 	    Bi  - Bias vector for the ith layer.
% 	    TFi - Transfer function of ith layer, default = 'tansig'.
% 	    BTF - Backprop network training function, default = 'traingdx'.
% 	    BLF - Backprop weight/bias learning function, default = 'learngdm'.
% 	    PF  - Performance function, default = 'mse'.
% 	  and returns a feed-forward network.
% 
% 	  The training function BTF can be any of the backprop training
% 	  functions such as TRAINGD, TRAINGDM, TRAINGDA, TRAINGDX, or TRAINLM.
% 
% 	  The learning function BLF can be either of the backpropagation
% 	  learning functions such as LEARNGD, or LEARNGDM.
% 
% 	  The performance function can be any of the differentiable performance
% 	  functions such as MSE or MSEREG.
% 
% 	  Once a network has been updated it can be simulated,
% 	  initialized, or trained with SIM, INIT, ADAPT, and TRAIN.
% 
% 	

function nnt2hop
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNT2HOP Update NNT 2.0 Hopfield recurrent network to NNT 3.0.
% 
% 	Syntax
% 
% 	  net = nnt2p(w,b)
% 
% 	Description
% 
% 	  NNT2HOP(W,B) takes these arguments,
% 	    W   - SxS weight matrix.
% 	    B   - Sx1 bias vector
% 	  and returns a perceptron.
% 
% 	  Once a network has been updated it can be simulated,
% 	  initialized, adapted, or trained with SIM, INIT, ADAPT, and TRAIN.
% 	  
% 	

function nnt2lin
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNT2LIN Update NNT 2.0 linear layer to NNT 3.0.
% 
% 	Syntax
% 
% 	  net = nnt2lin(pr,w,b,lr)
% 
% 	Description
% 
% 	  NNT2LIN(PR,W,B) takes these arguments,
% 	    PR - Rx2 matrix of min and max values for R input elements.
% 	    W  - SxR weight matrix.
% 	    B  - Sx1 bias vector
% 	    LR - Learning rate, default = 0.01;
% 	  and returns a linear layer.
% 
% 	  Once a network has been updated it can be simulated, initialized,
% 	  adapted, or trained with SIM, INIT, ADAPT, and TRAIN.
% 
% 	

function nnt2lvq
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNT2LVQ Update NNT 2.0 learning vector quantization network to NNT 3.0.
% 
% 	Syntax
% 
% 	  net = nnt2lvq(pr,w1,w2,lr,lf)
% 
% 	Description
% 
% 	  NNT2LVQ(PR,W1,W2,LR,LF) takes these arguments,
% 	    PR - Rx2 matrix of min and max values for R input elements.
% 	    W1 - S1xR weight matrix.
% 	    W2 - S2xS1 weight matrix.
% 	    LR - learning rate, default = 0.01.
% 	    LF - Learning function, default = 'learnlv2'.
% 	  and returns an LVQ network.
% 
%      The learning function LF can be LEARNLV1 or LEARNLV2.
% 
% 	  Once a network has been updated it can be simulated, initialized,
% 	  adapted, or trained with SIM, INIT, ADAPT, and TRAIN.
% 
% 	

function nnt2p
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNT2P Update NNT 2.0 perceptron to NNT 3.0.
% 
% 	Syntax
% 
% 	  net = nnt2p(pr,w,b,tf,lf)
% 
% 	Description
% 
% 	  NNT2P(PR,W,B,TF,LF) takes these arguments,
% 	    PR  - Rx2 matrix of min and max values for R input elements.
% 	    W   - SxR weight matrix.
% 	    B   - Sx1 bias vector
% 	    TF - Transfer function, default = 'hardlim'.
% 	    LF - Learning function, default = 'learnp'.
% 	  and returns a perceptron.
% 
% 	  The transfer function TF can be HARDLIM or HARDLIMS.
% 	  The learning function LF can be LEARNP or LEARNPN.
% 
% 	  Once a network has been updated it can be simulated, initialized,
% 	  adapted, or trained with SIM, INIT, ADAPT, and TRAIN.
% 	  
% 	

function nnt2rb
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNT2RB Update NNT 2.0 radial basis network to NNT 3.0.
% 
% 	Syntax
% 
% 	  net = nnt2rb(pr,w1,b1,w2,b2)
% 
% 	Description
% 
% 	  NNT2RB(PR,W1,B1,W2,B2) takes these arguments,
% 	    PR - Rx2 matrix of min and max values for R input elements.
% 	    W1 - S1xR weight matrix.
% 	    B1 - S1x1 bias vector.
% 	    W2 - S2xS1 weight matrix.
% 	    B2 - S2x1 bias vector.
% 	  and returns a radial basis network.
% 
% 	  Once a network has been updated it can be simulated, initialized,
% 	  adapted, or trained with SIM, INIT, ADAPT, and TRAIN.
% 
% 	

function nnt2som
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNT2SOM Update NNT 2.0 self-organizing map to NNT 3.0.
% 
% 	Syntax
% 
% 	  net = nnt2som(pr,[d1 d2 ...],w,olr,osteps,tlr,tnd)
% 
% 	Description
% 
% 	  NNT2SOM(PR,[D1,D2,...],W,OLR,OSTEPS,TLR,TDN) takes these arguments,
% 	    PR     - Rx2 matrix of min and max values for R input elements.
% 	    Di     - Size of ith layer dimension.
% 	    W      - SxR weight matrix.
% 	    OLR    - Ordering phase learning rate, default = 0.9.
% 	    OSTEPS - Ordering phase steps, default = 1000.
% 	    TLR    - Tuning phase learning rate, default = 0.02;
% 	    TND    - Tuning phase neighborhood distance, default = 1.
% 	  Returns a self-organizing map.
% 
% 	  NNT2SOM assumes that the self-organizing map has a
% 	  grid topology (GRIDTOP) using link distances (LINKDIST).
% 	  This corresponds with the NBMAN neighborhood function
% 	  in NNT 2.0.
% 
% 	  The new network will only output 1 for the neuron with the greatest
% 	  net input.  In NNT2 the network would also output 0.5 for that neuron's
% 	  neighbors.
% 
% 	  Once a network has been updated it can be simulated, initialized,
% 	  adapted, or trained with SIM, INIT, ADAPT, and TRAIN.
% 	  
% 	

function sim
%MATLAB Tour Partial Function Help:  nnt_con
%
% SIM Simulate a Simulink model
%    SIM('model') will simulate your Simulink model using all simulation
%    parameter dialog settings including Workspace I/O options.
% 
%    The SIM command also takes the following parameters. By default
%    time, state, and output are saved to the specified left hand side
%    arguments unless OPTIONS overrides this. If there are no left hand side
%    arguments, then the simulation parameters dialog Workspace I/O settings
%    are used to specify what data to log.
% 
%    [T,X,Y]         = SIM('model',TIMESPAN,OPTIONS,UT)
%    [T,X,Y1,...,Yn] = SIM('model',TIMESPAN,OPTIONS,UT)
% 
%        T            : Returned time vector.
%        X            : Returned state in matrix or structure format. 
%                       The state matrix contains continuous states followed by 
%                       discrete states. 
%        Y            : Returned output in matrix or structure format. 
%                       For block diagram models this contains all root-level 
%                       outport blocks.
%        Y1,...,Yn    : Can only be specified for block diagram models, where n
%                       must be the number of root-level outport blocks. Each
%                       outport will be returned in the Y1,...,Yn variables.
% 
%        'model'      : Name of a block diagram model.
%        TIMESPAN     : One of:
%                         TFinal,
%                         [TStart TFinal], or
%                         [TStart OutputTimes TFinal].
%                       OutputTimes are time points which will be returned in
%                       T, but in general T will include additional time points.
%        OPTIONS      : Optional simulation parameters. This is a structure
%                       created with SIMSET using name value pairs.
%        UT           : Optional extern input.  UT = [T, U1, ... Un]
%                       where T = [t1, ..., tm]' or UT is a string containing a
%                       function u=UT(t) evaluated at each time step.  For
%                       table inputs, the input to the model is interpolated
%                       from UT.
% 
%    Specifying any right hand side argument to SIM as the empty matrix, [],
%    will cause the default for the argument to be used.
% 
%    Only the first parameter is required. All defaults will be taken from the
%    block diagram, including unspecified options.  Any optional arguments
%    specified will override the settings in the block diagram.
% 
%    

function init
%MATLAB Tour Partial Function Help:  nnt_con
%
% --- help for network/init.m ---
%
% INIT Initialize a neural network.
% 
% 	Syntax
% 
% 	  net = init(net)
% 
% 	Description
% 
% 	  INIT(NET) returns neural network NET with weight and bias values
% 	  updated according to the network initialization function, indicated
% 	  by NET.initFcn, and the parameter values, indicated by NET.initParam.
% 
% 	Examples
% 
% 	  Here a perceptron is created with a 2-element input (with ranges
% 	  of 0 to 1, and -2 to 2) and 1 neuron.  Once it is created we can display
% 	  the neuron's weights and bias.
% 
% 	    net = newp([0 1;-2 2],1);
% 	    net.iw{1,1}
% 	    net.b{1}
% 
% 	  Training the perceptron alters its weight and bias values.
% 
% 	    P = [0 1 0 1; 0 0 1 1];
% 	    T = [0 0 0 1];
% 	    net = train(net,P,T);
% 	    net.iw{1,1}
% 	    net.b{1}
% 
% 	  INIT reinitializes those weight and bias values.
% 
% 	    net = init(net);
% 	    net.iw{1,1}
% 	    net.b{1}
% 
% 	  The weights and biases are zeros again, which are the initial values
% 	  used by perceptron networks (see NEWP). 
% 
% 	Algorithm
% 
% 	  INIT calls NET.initFcn to initialize the weight and bias values
% 	  according to the parameter values NET.initParam.
% 
% 	  Typically, NET.initFcn is set to 'initlay' which initializes each
% 	  layer's weights and biases according to its NET.layers{i}.initFcn.
% 
% 	  Backpropagation networks have NET.layers{i}.initFcn set to 'initnw'
% 	  which calculates the weight an bias values for layer i using the
% 	  Nguyen-Widrow initialization method.
% 
% 	  Other networks have NET.layers{i}.initFcn set to 'initwb', which
% 	  initializes each weight and bias with its own initialization function.
% 	  The most common weight and bias initialization function is RANDS
% 	  which generates random values between -1 and 1.
% 
% 	

function adapt
%MATLAB Tour Partial Function Help:  nnt_con
%
% --- help for network/adapt.m ---
%
% ADAPT Allow a neural network to adapt.
% 
% 	Syntax
% 
% 	  [net,Y,E,Pf,Af] = adapt(NET,P,T,Pi,Ai)
% 
% 	Description
% 
% 	  [NET,Y,E,Pf,Af] = ADAPT(NET,P,T,Pi,Ai) takes,
% 	    NET - Network.
% 	    P   - Network inputs.
% 	    T   - Network targets, default = zeros.
% 	    Pi  - Initial input delay conditions, default = zeros.
% 	    Ai  - Initial layer delay conditions, default = zeros.
% 	  and returns the following after applying the adapt function
% 	  NET.adaptFcn with the adaption parameters NET.adaptParam:
% 	    NET - Updated network.
% 	    Y   - Network outputs.
% 	    E   - Network errors.
% 	    Pf  - Final input delay conditions.
% 	    Af  - Final layer delay conditions.
% 
% 	  Note that T is optional and only needs to be used for networks
% 	  that require targets.  Pi and Pf are also optional and need
% 	  only to be used for networks that have input or layer delays.
% 
% 	  ADAPT's signal arguments can have two formats: cell array or matrix.
% 	  
% 	  The cell array format is easiest to describe.  It is most
% 	  convenient to be used for networks with multiple inputs and outputs,
% 	  and allows sequences of inputs to be presented:
% 	    P  - NixTS cell array, each element P{i,ts} is an RixQ matrix.
% 	    T  - NtxTS cell array, each element P{i,ts} is an VixQ matrix.
% 	    Pi - NixID cell array, each element Pi{i,k} is an RixQ matrix.
% 		Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
% 		Y  - NOxTS cell array, each element Y{i,ts} is an UixQ matrix.
% 	    Pf - NixID cell array, each element Pf{i,k} is an RixQ matrix.
% 		Af - NlxLD cell array, each element Af{i,k} is an SixQ matrix.
% 	  Where:
% 	    Ni = net.numInputs
% 		Nl = net.numLayers
% 	    No = net.numOutputs
% 	    Nt = net.numTargets
% 		ID = net.numInputDelays
% 		LD = net.numLayerDelays
% 	    TS = number of time steps
% 	    Q  = batch size
% 	    Ri = net.inputs{i}.size
% 	    Si = net.layers{i}.size
% 	    Ui = net.outputs{i}.size
% 	    Vi = net.targets{i}.size
% 
% 	  The columns of Pi, Pf, Ai, and Af are ordered from oldest delay
% 	  condition to most recent:
% 	    Pi{i,k} = input i at time ts=k-ID.
% 	    Pf{i,k} = input i at time ts=TS+k-ID.
% 	    Ai{i,k} = layer output i at time ts=k-LD.
% 	    Af{i,k} = layer output i at time ts=TS+k-LD.
% 
% 	  The matrix format can be used if only one time step is to be
% 	  simulated (TS = 1).  It is convenient for network's with
%      only one input and output, but can be used with networks that
%      have more.
% 
% 	  Each matrix argument is found by storing the elements of
% 	  the corresponding cell array argument into a single matrix:
% 	    P  - (sum of Ri)xQ matrix
% 	    T  - (sum of Vi)xQ matrix
% 	    Pi - (sum of Ri)x(ID*Q) matrix.
% 		Ai - (sum of Si)x(LD*Q) matrix.
% 		Y  - (sum of Ui)xQ matrix.
% 	    Pf - (sum of Ri)x(ID*Q) matrix.
% 		Af - (sum of Si)x(LD*Q) matrix.
% 
% 	Examples
% 
% 	  Here two sequences of 12 steps (where T1 is known to depend
% 	  on P1) are used to define the operation of a filter.
% 
% 	    p1 = {-1  0 1 0 1 1 -1  0 -1 1 0 1};
% 	    t1 = {-1 -1 1 1 1 2  0 -1 -1 0 1 1};
% 
% 	  Here NEWLIN is used to create a layer with an input range
% 	  of [-1 1]), one neuron, input delays of 0 and 1, and a
% 	  learning rate of 0.5. The linear layer is then simulated.
% 
% 	    net = newlin([-1 1],1,[0 1],0.5);
% 
% 	  Here the network adapts for one pass through the sequence.
% 	  The network's mean squared error is displayed.  (Since this
% 	  is the first call of ADAPT the default Pi is used.)
% 
% 	    [net,y,e,pf] = adapt(net,p1,t1);
% 	    mse(e)
% 	    
% 	  Note the errors are quite large.  Here the network adapts
% 	  to another 12 time steps (using the previous Pf as the
% 	  new initial delay conditions.)
% 
% 	    p2 = {1 -1 -1 1 1 -1  0 0 0 1 -1 -1};
% 	    t2 = {2  0 -2 0 2  0 -1 0 0 1  0 -1};
% 	    [net,y,e,pf] = adapt(net,p2,t2,pf);
% 	    mse(e)
% 
% 	  Here the network adapts for 100 passes through the entire
% 	  sequence.
% 
% 	    p3 = [p1 p2];
% 	    t3 = [t1 t2];
% 	    net.adaptParam.passes = 100;
% 	    [net,y,e] = adapt(net,p3,t3);
% 	    mse(e)
% 
% 	  The error after 100 passes through the sequence is very
% 	  small - the network has adapted to the relationship
% 	  between the input and target signals.
% 
% 	Algorithm
% 
% 	  ADAPT calls the function indicated by NET.adaptFcn, using the
% 	  adaption parameter values indicated by NET.adaptParam.
% 
% 	  Given an input sequence with TS steps the network is
% 	  updated as follows.  Each step in the sequence of	inputs is
% 	  presented to the network one at a time.  The network's weight and
% 	  bias values are updated after each step, before the next step in
% 	  the sequence is presented. Thus the network is updated TS times.
% 
% 	

function train
%MATLAB Tour Partial Function Help:  nnt_con
%
% --- help for network/train.m ---
%
%   TRAIN Train a neural network.
% 
%   Syntax
% 
%     [net,tr] = train(NET,P,T,Pi,Ai)
%     [net,tr] = train(NET,P,T,Pi,Ai,VV,TV)
% 
%   Description
% 
%    TRAIN trains a network NET according to NET.trainFcn and
%     NET.trainParam.
% 
%     TRAIN(NET,P,T,Pi,Ai) takes,
%       NET - Network.
%       P   - Network inputs.
%       T   - Network targets, default = zeros.
%       Pi  - Initial input delay conditions, default = zeros.
%       Ai  - Initial layer delay conditions, default = zeros.
%     and returns,
%       NET - New network.
%       TR  - Training record (epoch and perf).
% 
%     Note that T is optional and need only be used for networks
%     that require targets.  Pi and Ai are also optional and need
%     only be used for networks that have input or layer delays.
% 
%     TRAIN's signal arguments can have two formats: cell array or matrix.
%     
%     The cell array format is easiest to describe.  It is most
%     convenient for networks with multiple inputs and outputs,
%     and allows sequences of inputs to be presented:
%       P  - NixTS cell array, each element P{i,ts} is an RixQ matrix.
%       T  - NtxTS cell array, each element P{i,ts} is an VixQ matrix.
%       Pi - NixID cell array, each element Pi{i,k} is an RixQ matrix.
%       Ai - NlxLD cell array, each element Ai{i,k} is an SixQ matrix.
%     Where:
%       Ni = net.numInputs
%       Nl = net.numLayers
%       Nt = net.numTargets
%       ID = net.numInputDelays
%       LD = net.numLayerDelays
%       TS = number of time steps
%       Q  = batch size
%       Ri = net.inputs{i}.size
%       Si = net.layers{i}.size
%       Vi = net.targets{i}.size
% 
%     The columns of Pi and Ai are ordered from the oldest delay
%     condition to most recent:
%       Pi{i,k} = input i at time ts=k-ID.
%       Ai{i,k} = layer output i at time ts=k-LD.
% 
%     The matrix format can be used if only one time step is to be
%     simulated (TS = 1).  It is convenient for network's with
%     only one input and output, but can be used with networks that
%     have more.
% 
%     Each matrix argument is found by storing the elements of
%     the corresponding cell array argument into a single matrix:
%       P  - (sum of Ri)xQ matrix
%       T  - (sum of Vi)xQ matrix
%       Pi - (sum of Ri)x(ID*Q) matrix.
%       Ai - (sum of Si)x(LD*Q) matrix.
% 
%     TRAIN(NET,P,T,Pi,Ai,VV,TV) takes optional structures of validation
%     and test vectors,
%       VV.P,  TV.P  - Validation/test inputs.
%       VV.T,  TV.T  - Validation/test targets, default = zeros.
%       VV.Pi, TV.Pi - Validation/test initial input delay conditions, default = zeros.
%       VV.Ai, TV.Ai - Validation/test layer delay conditions, default = zeros.
%     The validation vectors are used to stop training early if further
%     training on the primary vectors will hurt generalization to the
%     validation vectors.  Test vector performance can be used to measure
%     how well the network generalizes beyond primary and validation vectors.
%     If VV.T, VV.Pi, or VV.Ai are set to an empty matrix or cell array,
%     default values will be used. The same is true for VT.T, VT.Pi, VT.Ai.
% 
%   Examples
% 
%     Here input P and targets T define a simple function which
%     we can plot:
% 
%       p = [0 1 2 3 4 5 6 7 8];
%       t = [0 0.84 0.91 0.14 -0.77 -0.96 -0.28 0.66 0.99];
%       plot(p,t,'o')
% 
%     Here NEWFF is used to create a two layer feed forward network.
%     The network will have an input (ranging from 0 to 8), followed
%     by a layer of 10 TANSIG neurons, followed by a layer with 1
%     PURELIN neuron.  TRAINLM backpropagation is used.  The network
%     is also simulated.
% 
%       net = newff([0 8],[10 1],{'tansig' 'purelin'},'trainlm');
%       y1 = sim(net,p)
%       plot(p,t,'o',p,y1,'x')
% 
%     Here the network is trained for up to 50 epochs to a error goal of
%     0.01, and then resimulated.
% 
%       net.trainParam.epochs = 50;
%       net.trainParam.goal = 0.01;
%       net = train(net,p,t);
%       y2 = sim(net,p)
%       plot(p,t,'o',p,y1,'x',p,y2,'*')
%       
%   Algorithm
% 
%     TRAIN calls the function indicated by NET.trainFcn, using the
%     adaption parameter values indicated by NET.trainParam.
% 
%     Typically one epoch of training is defined as a single presentation
%     of all input vectors to the network.  The network is then updated
%     according to the results of all those presentations.
% 
%     Training occurs until a maximum number of epochs occurs, the
%     performance goal is met, or any other stopping condition of the
%     function NET.trainFcn occurs.
% 
%     Some training functions depart from this norm by presenting only
%     one input vector (or sequence) each epoch. An input vector (or sequence)
%     is chosen randomly each epoch from concurrent input vectors (or sequences).
%     NEWC and NEWSOM return networks that use TRAINWB1, a training function
%     that does this.
% 
%   

function disp
%MATLAB Tour Partial Function Help:  nnt_con
%
% DISP Display array.
%    DISP(X) displays the array, without printing the array name.  In
%    all other ways it's the same as leaving the semicolon off an
%    expression except that empty arrays don't display.
% 
%    If X is a string, the text is displayed.
% 
%    

function display
%MATLAB Tour Partial Function Help:  nnt_con
%
% DISPLAY Display array.
%    DISPLAY(X) is called for the object X when the semicolon is not used
%    to terminate a statement. 
% 
%    For example,
%      X = inline('sin(x)')
%    calls DISPLAY(X) while
%      X = inline('sin(x)');
%    does not.
% 
%    A typical implementation of DISPLAY calls DISP to do most of the work
%    and looks like this
% 
%       function display(X)
%       if isequal(get(0,'FormatSpacing'),'compact')
%          disp([inputname(1) ' =']);
%          disp(X)
%       else
%          disp(' ')
%          disp([inputname(1) ' =']);
%          disp(' ');
%          disp(X)
%       end
%    
%    

function cell2mat
%MATLAB Tour Partial Function Help:  nnt_con
%
% CELL2MAT Combine a cell array of matrices into one matrix.
% 
% 	Synopsis
% 
% 	  m = cell2mat(c)
% 
% 	Description
% 
% 	  M = CELL2MAT(C)
% 	    C - Cell array of matrices: {M11 M12... ; M21 M22... ; ...}
% 	  returns
% 	    M - Single matrix: [M11 M12 ...; M21 M22... ; ...]
% 
% 	Examples
% 
% 	  c = {[1 2] [3]; [4 5; 6 7] [8; 9]};
% 	  m = cell2mat(c)
% 
% 	

function concur
%MATLAB Tour Partial Function Help:  nnt_con
%
% CONCUR Create concurrent bias vectors.
% 
% 	Syntax
% 
% 	  concur(b,q)
% 
% 	Description
% 
% 	  CONCUR(B,Q)
% 	    B - Nlx1 cell array of bias vectors.
% 	    Q - Concurrent size.
% 	  Returns an SxB matrix of copies of B (or Nlx1 cell array of matrices).
% 
% 	Examples
% 	
% 	  Here CONCUR creates three copies of a bias vector.
% 
% 	    b = [1; 3; 2; -1];
% 	    concur(b,3)
% 
% 	Network Use
% 
% 	  To calculate a layer's net input, the layer's weighted
% 	  inputs must be combined with its biases.  The following
% 	  expression calculates the net input for a layer with
% 	  the NETSUM net input function, two input weights, and
% 	  a bias:
% 
% 	    n = netsum(z1,z2,b)
% 
% 	  The above expression works if Z1, Z2, and B are all Sx1
% 	  vectors.  However, if the network is being simulated by SIM
% 	  (or ADAPT or TRAIN) in response to Q concurrent vectors,
% 	  then Z1 and Z2 will be SxQ matrices.  Before B can be
% 	  combined with Z1 and Z2 we must make Q copies of it.
% 
% 	    n = netsum(z1,z2,concur(b,q))
% 	  
% 	

function con2seq
%MATLAB Tour Partial Function Help:  nnt_con
%
% CON2SEQ Convert concurrent vectors to sequential vectors.
% 
% 	Syntax
% 	
% 	  s = con2seq(b)
% 
% 	Description
% 
% 	  The neural network toolbox arranges concurrent vectors
% 	  with a matrix, and sequential vectors with a cell array
% 	  (where the second index is the time step).
% 
% 	  CON2SEQ and SEQ2CON allow concurrent vectors to be converted
% 	  to sequential vectors, and back again.
% 
% 	  CON2SEQ(B) takes one input,
% 	    B - RxTS matrix.
% 	  and returns one output,
% 	    S - 1xTS cell array of Rx1 vectors.
% 
% 	  CON2SEQ(B,TS) can also convert multiple batches,
% 	    B  - Nx1 cell array of matrices with M*TS columns.
% 	    TS - Time steps.
% 	  and will return,
% 	    S - NxTS cell array of matrices with M columns.
% 
% 	Example
% 
% 	  Here a batch of three values is converted to a
% 	  sequence.
% 
% 	    p1 = [1 4 2]
% 	    p2 = con2seq(p1)
% 
% 	  Here two batches of vectors are converted to a
% 	  two sequences with two time steps.
% 
% 	    p1 = {[1 3 4 5; 1 1 7 4]; [7 3 4 4; 6 9 4 1]}
% 	    p2 = con2seq(p1,2)
% 
% 	

function combvec
%MATLAB Tour Partial Function Help:  nnt_con
%
% COMBVEC Create all combinations of vectors.
% 
% 	Syntax
% 
% 	  combvec(a1,a2)
% 
% 	Description
% 
% 	  COMBVEC(A1,A2) takes two inputs,
% 	    A1 - Matrix of N1 (column) vectors.
% 	    A2 - Matrix of N2 (column) vectors.
% 	  and returns a matrix of N1*N2 column vectors, where the columns
% 	  consist of all possibilities of A2 vectors, appended to
% 	  A1 vectors.
% 
% 	Example
% 	
% 	  a1 = [1 2 3; 4 5 6];
% 	  a2 = [7 8; 9 10];
% 	  a3 = combvec(a1,a2)

function ind2vec
%MATLAB Tour Partial Function Help:  nnt_con
%
% IND2VEC Convert indices to vectors.
% 
% 	Syntax
% 
% 	  vec = ind2vec(ind)
% 
% 	Description
% 
% 	  IND2VEC and VEC2IND allow indices to be represented
% 	  either by themselves, or as vectors containing a 1 in the
% 	  row of the index they represent.
% 
% 	  IND2VEC(IND) takes one argument,
% 	    IND - Row vector of indices.
% 	  and returns sparse matrix of vectors, with one 1 in
% 	  each column, as indicated by IND.
% 
% 	Examples
% 
% 	  Here four indices are defined and converted to vector
% 	  representation.
% 
% 	    ind = [1 3 2 3]
% 	    vec = ind2vec(ind)
% 
% 	

function mat2cell
%MATLAB Tour Partial Function Help:  nnt_con
%
% MAT2CELL Break matrix up into a cell array of matrices.
% 
% 	Synopsis
% 
% 	  mat2cell(M,R,C);
% 
% 	Description
% 
% 	  MAT2CELL(M,R,C) takes three arguments,
% 	    M - ROWxCOL Matrix.
% 	    R - Vector of row sizes (should sum to ROW).
% 	    C - Vector of col sizes (should sum to COL).
% 	  and returns a cell array of matrices, found using R and C.
% 
% 	Example
% 
% 	   M = [1 2 3 4; 5 6 7 8; 9 10 11 12];
% 	   C = mat2cell(M,[1 2],[2 2])
% 	    
% 	

function minmax
%MATLAB Tour Partial Function Help:  nnt_con
%
% MINMAX Ranges of matrix rows.
% 
% 	Syntax
% 
% 	  pr = range(P)
% 
% 	Description
% 
% 	  MINMAX(P) takes one argument,
% 	    PR - RxQ matrix.
% 	  and returns the Rx2 matrix PR of minimum and maximum values
% 	  for each row of M.
% 
% 	Examples
% 
% 	  p = [0 1 2; -1 -2 -0.5]
% 	  pr = minmax(p)

function nncopy
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNCOPY Copy matrix or cell array.
% 
% 	Syntax
% 
%      nncopy(x,m,n)
% 	
% 	Description
% 
% 	  NNCOPY(X,M,N) takes two arguments,
% 	    X - RxC matrix (or cell array).
% 	    M - Number of vertical copies.
% 	    N - Number of horizontal copies.
% 	  and returns a new (R*M)x(C*N) matrix (or cell array).
% 
% 	Examples
% 
% 	   x1 = [1 2 3; 4 5 6];
% 	   y1 = nncopy(x1,3,2)
% 	   x2 = {[1 2]; [3; 4; 5]}
% 	   y2 = nncopy(x2,2,3)

function normc
%MATLAB Tour Partial Function Help:  nnt_con
%
% NORMC Normalize columns of a matrix.
% 
% 	Syntax
% 
% 	  normc(M)
% 
% 	Description
% 
% 	  NORMC(M) normalizes the columns of M to a length of 1.
% 
% 	Examples
% 	  
% 	  m = [1 2; 3 4]
% 	  n = normc(m)
% 
% 	

function normr
%MATLAB Tour Partial Function Help:  nnt_con
%
% NORMR Normalize rows of a matrix.
% 
% 	Syntax
% 
% 	  normr(M)
% 
% 	Description
% 
% 	  NORMR(M) normalizes the columns of M to a length of 1.
% 
% 	Examples
% 
% 	  m = [1 2; 3 4]
% 	  n = normr(m)
% 
% 	

function pnormc
%MATLAB Tour Partial Function Help:  nnt_con
%
% PNORMC Pseudo-normalize columns of a matrix.
% 
% 	Syntax
% 
% 	  pnormc(x,r)
% 
% 	Description
% 	
% 	  PNORMC(M,R) takes these arguments,
% 	    X - MxN matrix.
% 	    R - (optional) radius to normalize columns to, default = 1.
% 	  returns X with an additional row of elements which results
% 	    in new column vector lengths of R.
% 	
% 	  WARNING: For this function to work properly, the columns of X must
% 	    originally have vector lengths less than R.
% 
% 	Examples
% 
% 	  x = [0.1 0.6; 0.3 0.1];
% 	  y = pnormc(x)
% 	
% 	

function quant
%MATLAB Tour Partial Function Help:  nnt_con
%
% QUANT Discretize values as multiples of a quantity.
% 
% 	Syntax
% 
% 	  quant(x,q)
% 
% 	Description
% 
% 	  QUANT(X,Q) takes these inputs,
% 	    X - Matrix, vector or scalar.
% 	    Q - Minimum value.
% 	  and returns values in X rounded to nearest multiple of Q
% 	
% 	Examples
% 
% 	  x = [1.333 4.756 -3.897];
% 	  y = quant(x,0.1)

function seq2con
%MATLAB Tour Partial Function Help:  nnt_con
%
% SEQ2CON Convert sequential vectors to concurrent vectors.
% 
% 	Syntax
% 
% 	  b = seq2con(s)
% 
% 	Description
% 
% 	  The neural network toolbox represents batches of vectors
% 	  with a matrix, and sequences of vectors with multiple
% 	  columns of a cell array.
% 
% 	  SEQ2CON and CON2SEQ allow concurrent vectors to be converted
% 	  to sequential vectors, and back again.
% 
% 	  SEQ2CON(S) takes one input,
% 	    S - NxTS cell array of matrices with M columns.
% 	  and returns,
% 	    B - Nx1 cell array of matrices with M*TS columns.
% 
% 	Example
% 
% 	  Here three sequential values are converted to concurrent values.
% 
% 	    p1 = {1 4 2}
% 	    p2 = seq2con(p1)
% 
% 	  Here two sequences of vectors over three time steps
% 	  are converted to concurrent vectors.
% 
% 	    p1 = {[1; 1] [5; 4] [1; 2]; [3; 9] [4; 1] [9; 8]}
% 	    p2 = seq2con(p1)
% 
% 	

function sumsqr
%MATLAB Tour Partial Function Help:  nnt_con
%
% SUMSQR Sum squared elements of a matrix.
% 
% 	Synopsis
% 
% 	  sumsqr(m)
% 
% 	Description
% 
% 	  SUMSQR(M) returns the sum of the squared elements in M.
% 
% 	Examples
% 
% 	  s = sumsqr([1 2;3 4])

function vec2ind
%MATLAB Tour Partial Function Help:  nnt_con
%
% VEC2IND Transform vectors to indices.
% 
% 	Syntax
% 
% 	  ind = vec2ind(vec)
% 
% 	Description
% 
% 	  IND2VEC and VEC2IND allow indices to be represented
% 	  either by themselves or as vectors containing a 1 in the
% 	  row of the index they represent.
% 
% 	  VEC2IND(VEC) takes one argument,
% 	    VEC - Matrix of vectors, each containing a single 1.
% 	  and returns the indices of the 1's.
% 
% 	Examples
% 
% 	  Here four vectors (containing only one 1 each) are defined
% 	  and the indices of the 1's are found.
% 
% 	    vec = [1 0 0 0; 0 0 1 0; 0 1 0 1]
% 	    ind = vec2ind(vec)
% 	
% 	

function dotprod
%MATLAB Tour Partial Function Help:  nnt_con
%
% DOTPROD Dot product weight function.
% 
% 	Syntax
% 
% 	  Z = dotprod(W,P)
% 	  df = dotprod('deriv')
% 
% 	Description
% 
% 	  DOTPROD is the dot product weight function.  Weight functions
% 	  apply weights to an input to get weighted inputs.
% 
% 	  DOTPROD(W,P) takes these inputs,
% 	    W - SxR weight matrix.
% 	    P - RxQ matrix of Q input (column) vectors.
% 	  and returns the SxQ dot product of W and P.
% 
% 	Examples
% 
% 	  Here we 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 NEWP or NEWLIN.
% 
% 	  To change a network so an input weight uses DOTPROD set
% 	  NET.inputWeight{i,j}.weightFcn to 'dotprod.  For a layer weight
% 	  set NET.inputWeight{i,j}.weightFcn to 'dotprod.
% 
% 	  In either case, call SIM to simulate the network with DOTPROD.
% 	  See NEWP and NEWLIN for simulation examples.
% 
% 	

function negdist
%MATLAB Tour Partial Function Help:  nnt_con
%
% NEGDIST Negative distance weight function.
% 
% 	Syntax
% 
% 	  Z = negdist(W,P)
% 	  df = negdist('deriv')
% 
% 	Description
% 
% 	  NEGDIST is a weight function.  Weight functions apply
% 	  weights to an input to get weighted inputs.
% 
% 	  NEGDIST(W,P) takes these inputs,
% 	    W - SxR weight matrix.
% 	    P - RxQ matrix of Q input (column) vectors.
% 	  and returns the SxQ matrix of negative vector distances.
% 
% 	  NEGDIST('deriv') returns '' because NEGDIST does not have
% 	  a derivative function.
% 
% 	Examples
% 
% 	  Here we 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 = negdist(W,P)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses NEGDIST
% 	  by calling NEWC or NEWSOM.
% 
% 	  To change a network so an input weight uses NEGDIST, set
% 	  NET.inputWeight{i,j}.weightFcn to 'negdist'.  For a layer weight
% 	  set NET.inputWeight{i,j}.weightFcn to 'negdist'.
% 
% 	  In either case, call SIM to simulate the network with NEGDIST.
% 	  See NEWC or NEWSOM for simulation examples.
% 
% 	Algorithm
% 
% 	  NEGDIST returns the negative Euclidean distance:
% 
% 	    z = -sqrt(sum(w-p)^2)
% 
% 	

function normprod
%MATLAB Tour Partial Function Help:  nnt_con
%
% NORMPROD Normalized dot product weight function.
% 
% 	Syntax
% 
% 	  Z = normprod(W,P)
% 	  df = normprod('deriv')
% 
% 	Description
% 
% 	  NORMPROD is a weight function.  Weight functions apply
% 	  weights to an input to get weighted inputs.
% 
% 	  NORMPROD(W,P) takes these inputs,
% 	    W - SxR weight matrix.
% 	    P - RxQ matrix of Q input (column) vectors.
% 	  and returns the SxQ matrix of normalized dot products.
% 
% 	  NORMPROD('deriv') returns '' because NORMPROD does not have
% 	  a derivative function.
% 
% 	Examples
% 
% 	  Here we 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 = normprod(W,P)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses NORMPROD
% 	  by calling NEWGRNN.
% 
% 	  To change a network so an input weight uses NORMPROD, set
% 	  NET.inputWeight{i,j}.weightFcn to 'normprod.  For a layer weight
% 	  set NET.inputWeight{i,j}.weightFcn to 'normprod.
% 
% 	  In either case, call SIM to simulate the network with NORMPROD.
% 	  See NEWGRNN for simulation examples.
% 
% 	Algorithm
% 
% 	  NORMPROD returns the dot product normalized by the sum
% 	  of the input vector elements.
% 
% 	    z = w*p/sum(p)
% 
% 	

function initcon
%MATLAB Tour Partial Function Help:  nnt_con
%
% INITCON Conscience bias initialization function.
% 	
% 	Syntax
% 
% 	  b = initcon(s,pr);
% 
%    Description
% 
% 	  INITCON is a bias initialization function that initializes
% 	  biases for learning with the LEARNCON learning function.
% 
% 	 INITCON (S,PR) takes two arguments
% 	    S  - Number of rows (neurons).
% 	    PR - Rx2 matrix of R = [Pmin Pmax], default = [1 1].
% 	  and returns an Sx1 bias vector.
% 
% 	  Note that for biases, R is always 1.  INITCON could
% 	  also be used to initialize weights, but it is not
% 	  recommended for that purpose.
% 
% 	Examples
% 
% 	  Here initial bias values are calculated a 5 neuron layer.
% 
% 	    b = initcon(5)
% 
% 	Network Use
% 
% 	  You can create a standard network that uses INITCON to initialize
% 	  weights by calling NEWC.
% 
% 	  To prepare the bias of layer i of a custom network
% 	  to initialize with INITCON:
% 	  1) Set NET.initFcn to 'initlay'.
% 	     (NET.initParam will automatically become INITLAY's default parameters.)
% 	  2) Set NET.layers{i}.initFcn to 'initwb'.
% 	  3) Set NET.biases{i}.initFcn to 'initcon'.
% 
% 	  To initialize the network call INIT.
% 
% 	  See NEWC for initialization examples.
% 
% 	Algorithm
% 
% 	  LEARNCON updates biases so that each bias value b(i) is
% 	  a function of the average output c(i) of the neuron i associated
% 	  with the bias.
% 
% 	  INITCON gets initial bias values by assuming that each
% 	  neuron has responded to equal numbers of vectors in the "past".
% 
% 	

function initzero
%MATLAB Tour Partial Function Help:  nnt_con
%
% INITZERO Zero weight/bias initialization function.
% 	
% 	Syntax
% 
% 	  W = initzero(S,PR)
% 	  b = initzero(S,[1 1])
% 
% 	Description
% 
% 	  INITZERO(S,PR) takes these arguments,
% 	    S - Number of rows (neurons).
% 	    PR - Rx2 matrix of input value ranges = [Pmin Pmax].
% 	  and returns an SxR weight matrix of zeros.
% 
% 	  INITZERO(S,[1 1])
% 	  returns an Sx1 bias vector of zeros.
% 	
% 	Examples
% 
% 	  Here initial weights and biases are calculated for
% 	  a layer with two inputs ranging over [0 1] and [-2 2],
% 	  and 4 neurons.
% 
% 	    W = initzero(5,[0 1; -2 2])
% 	    b = initzero(5,[1 1])
% 
% 	Network Use
% 
% 	  You can create a standard network that uses INITZERO to initialize
% 	  its weights by calling NEWP or NEWLIN.
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to be initialized with MIDPOINT:
% 	  1) Set NET.initFcn to 'initlay'.
% 	     (NET.initParam will automatically become INITLAY's default parameters.)
% 	  2) Set NET.layers{i}.initFcn to 'initwb'.
% 	  3) Set each NET.inputWeights{i,j}.initFcn to 'initzero'.
% 	     Set each NET.layerWeights{i,j}.initFcn to 'initzero';
% 	     Set each NET.biases{i}.initFcn to 'initzero';
% 
% 	  To initialize the network call INIT.
% 
% 	  See NEWP or NEWLIN for initialization examples.
% 
% 	

function midpoint
%MATLAB Tour Partial Function Help:  nnt_con
%
% MIDPOINT Midpoint weight initialization function.
% 
% 	Syntax
% 
% 	  W = midpoint(S,PR)
% 
% 	Description
% 
% 	  MIDPOINT is a weight initialization function that
% 	  sets weight (row) vectors to the center of the
% 	  input ranges.
% 	
% 	MIDPOINT(S,PR) takes two arguments,
% 	  S  - Number of rows (neurons).
% 	  PR - Rx2 matrix of input value ranges = [Pmin Pmax].
% 	and returns an SxR matrix with rows set to (Pmin+Pmax)'/2.
% 	
% 	Examples
% 
% 	  Here initial weight values are calculated for a 5 neuron
% 	  layer with input elements ranging over [0 1] and [-2 2].
% 
% 	    W = midpoint(5,[0 1; -2 2])
% 
% 	Network Use
% 
% 	  You can create a standard network that uses MIDPOINT to initialize
% 	  weights by calling NEWC.
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to initialize with MIDPOINT:
% 	  1) Set NET.initFcn to 'initlay'.
% 	     (NET.initParam will automatically become INITLAY's default parameters.)
% 	  2) Set NET.layers{i}.initFcn to 'initwb'.
% 	  3) Set each NET.inputWeights{i,j}.initFcn to 'midpoint'.
% 	     Set each NET.layerWeights{i,j}.initFcn to 'midpoint';
% 
% 	  To initialize the network call INIT.
% 
% 	  See NEWC for initialization examples.
% 
% 	

function randnc
%MATLAB Tour Partial Function Help:  nnt_con
%
% RANDNC Normalized column weight initialization function.
% 
% 	Syntax
% 
% 	   W = randnc(S,PR)
% 	   W = randnc(S,R)
% 
% 	Description
% 
% 	  RANDNC is a weight initialization function.
% 
% 	  RANDNC(S,P) takes these inputs,
% 	    S  - Number of rows (neurons).
% 	    PR - Rx2 matrix of input value ranges = [Pmin Pmax].
% 	  and returns an SxR random matrix with normalized columns.
% 	
% 	  Can also be called as RANDNC(S,R).
% 	
% 	

function randnr
%MATLAB Tour Partial Function Help:  nnt_con
%
% RANDNR Normalized row weight initialization function.
% 
% 	Syntax
% 
% 	   W = randnr(S,PR)
% 	   W = randnr(S,R)
% 
% 	Description
% 
% 	  RANDNR is a weight initialization function.
% 
% 	  RANDNR(S,P) takes these inputs,
% 	    S  - Number of rows (neurons).
% 	    PR - Rx2 matrix of input value ranges = [Pmin Pmax].
% 	  and returns an SxR random matrix with normalized rows.
% 	
% 	  Can also be called as RANDNR(S,R).
% 	
% 	

function rands
%MATLAB Tour Partial Function Help:  nnt_con
%
% RANDS Symmetric random weight/bias initialization function.
% 
% 	Syntax
% 
% 	  W = rands(S,PR)
% 	  M = rands(S,R)
% 	  v = rands(S);
% 
% 	Description
% 
% 	  RANDS is a weight/bias initialization function.
% 
% 	  RANDS(S,PR) takes,
% 	    S  - number of neurons.
% 	    PR - Rx2 matrix of R input ranges.
% 	  and returns an S-by-R weight matrix of random values between -1 and 1.
% 
% 	  RANDS(S,R) returns an S-by-R matrix of random values.
% 	  RANDS(S) returns an S-by-1 vector of random values.
% 
% 	Examples
% 
% 	  Here three sets of random values are generated with RANDS.
% 
% 	    rands(4,[0 1; -2 2])
% 	    rands(4)
% 	    rands(2,3)
% 
% 	Network Use
% 
% 	  To prepare the weights and the bias of layer i of a custom network
% 	  to be initialized with RANDS:
% 	  1) Set NET.initFcn to 'initlay'.
% 	     (NET.initParam will automatically become INITLAY's default parameters.)
% 	  2) Set NET.layers{i}.initFcn to 'initwb'.
% 	  3) Set each NET.inputWeights{i,j}.initFcn to 'rands'.
% 	     Set each NET.layerWeights{i,j}.initFcn to 'rands';
% 	     Set each NET.biases{i}.initFcn to 'rands'.
% 
% 	  To initialize the network call INIT.
% 
% 	

function ddotprod
%MATLAB Tour Partial Function Help:  nnt_con
%
% DDOTPROD Dot product weight derivative function.
% 
% 	Syntax
% 	
% 	  dZ_dP = ddotprod('p',W,P,Z)
% 	  dZ_dW = ddotprod('w',W,P,Z)
% 
% 	Description
% 	
% 	  DDOTPROD is a weight derivative function.
% 
% 	  DDOTPROD('p',W,P,Z) takes three arguments,
% 	    W - SxR weight matrix.
%        P - RxQ Inputs.
% 	    Z - SxQ weighted input.
% 	  and returns the SxR derivative dZ/dP.
% 
% 	  DDOTPROD('w',W,P,Z) returns the RxQ derivative dZ/dW.
% 
% 	Examples
% 
% 	  Here we define a weight W and input P for an input with
% 	  3 elements and a layer with 2 neurons.
% 
% 	    W = [0 -1 0.2; -1.1 1 0];
% 	    P = [0.1; 0.6; -0.2];
% 	   
% 	  Here we calculate the weighted input with DOTPROD, then
% 	  calculate each derivative with DDOTPROD.
% 
% 	    Z = dotprod(W,P)
% 	    dZ_dP = ddotprod('p',W,P,Z)
% 	    dZ_dW = ddotprod('w',W,P,Z)
% 
% 	Algorithm
% 
% 	  The derivative of a product of two elements with respect to one
% 	  element is the other element.
% 
% 	    dZ/dP = W
% 	    dZ/dW = P
% 
% 	

function assoclr
%MATLAB Tour Partial Function Help:  nnt_con
%
%  Associative learning rules.
% 
%  Hebb learning.
%    learnh    - Hebb weight learning function.
%    learnhd   - Hebb with decay weight learning function.
% 
%  Grossberg learning.
%    learnis   - Instar weight learning function.
%    learnos   - Outstar weight learning function.
% 
%  Kohonen learning.
%    learnk    - Kohonen weight learning function.
% 
%  Demonstrations.
%    demoh1    - Hebbian association.
%    demoh2    - Vector frequencies and weight decay.
%    demois1   - Instar association.
%    demok1    - Kohonen association.
%    demoos1   - Outstar association.

function backprop
%MATLAB Tour Partial Function Help:  nnt_con
%
%  Backpropagation networks.
% 
%  New networks.
%    newff   - Create a feed-forward backpropagation network.
%    newcf   - Create a cascade-forward backpropagation network.
% 	newfftd - Create a feed-forward input-delay backprop network.
% 
%  Using networks.
%    sim      - Simulate a neural network.
%    init     - Initialize a neural network.
%    adapt    - Allow a neural network to adapt.
%    train    - Train a neural network.
% 
%  Weight functions.
%    dotprod  - Dot product weight function.
%    ddotprod - Dot product weight derivative function.
% 
%  Net input functions.
%    netsum   - Sum net input function.
%    dnetsum  - Sum net input derivative function.
% 
%  Transfer functions.
%    purelin  - Hard limit transfer function.
%    tansig   - Hyperbolic tangent sigmoid transfer function.
%    logsig   - Log sigmoid transfer function.
%    dpurelin - Hard limit transfer derivative function.
%    dtansig  - Hyperbolic tangent sigmoid transfer derivative function.
%    dlogsig  - Log sigmoid transfer derivative function.
% 
%  Performance.
%    mse      - Mean squared error performance function.
%    msereg   - Mean squared error w/reg performance function.
%    dmse     - Mean squared error performance derivatives function.
%    dmsereg  - Mean squared error w/reg performance derivative function.
% 
%  Initialization.
%    initlay  - Layer-by-layer network initialization function.
%    initnw   - Nguyen-Widrow layer initialization function.
% 
%  Learning.
%    learngd  - Backpropagation learning rule.
%    learngdm - Backpropagation learning rule with momentum.
% 
%  Adaption.
%    adaptwb  - By-weight-and-bias network adaption function.
% 
%  Training.
%    traingd  - Gradient descent backpropagation.
%    traingdm - Gradient descent w/momentum backpropagation.
%    traingda - Gradient descent w/adaptive lr backpropagation.
%    traingdx - Gradient descent w/momentum & adaptive lr backpropagation.
%    trainlm  - Levenberg-Marquardt backpropagation.
% 
%  Analysis functions.
%    errsurf  - Error surface.
% 
%  Plotting functions.
%    plotes   - Plot error surface.
%    plotep   - Plot weight and bias position on error surface.
% 
%  Demonstrations
%    demobp1  - Training a nonlinear neuron.
%    demobp2  - Local and global error minima.
%    demobp3  - Learning with momentum.
%    demobp4  - Learning rates.
%    demobp5  - Function approximation.
%    demobp6  - Faster approximation.
%    demolm1  - Fastest approximation.
%    demolm2  - Underfitting.
%    demolm3  - Overfitting.
%    appcs1   - Nonlinear system identification.
%    appcs2   - Feedback linearization.
%    appcr1   - Character recognition.

function elman
%MATLAB Tour Partial Function Help:  nnt_con
%
%  Elman recurrent networks.
% 
%  New networks.
%    newelm   - New Elman backpropagation network.
% 
%  Using networks.
%    sim      - Simulate a neural network.
%    init     - Initialize a neural network.
%    adapt    - Allow a neural network to adapt.
%    train    - Train a neural network.
% 
%  Weight functions.
%    dotprod  - Dot product weight function.
%    ddotprod - Dot product weight derivative function.
% 
%  Net input functions.
%    netsum   - Sum net input function.
%    dnetsum  - Sum net input derivative function.
% 
%  Transfer functions.
%    purelin  - Hard limit transfer function.
%    tansig   - Hyperbolic tangent sigmoid transfer function.
%    logsig   - Log sigmoid transfer function.
%    dpurelin - Hard limit transfer derivative function.
%    dtansig  - Hyperbolic tangent sigmoid transfer derivative function.
%    dlogsig  - Log sigmoid transfer derivative function.
% 
%  Performance.
%    mse      - Mean squared error performance function.
%    msereg   - Mean squared error w/reg performance function.
%    dmse     - Mean squared error performance derivatives function.
%    dmsereg  - Mean squared error w/reg performance derivative function.
% 
%  Learning.
%    learnbp  - Backpropagation learning rule.
%    learnbpm - Backpropagation learning rule with momentum.
% 
%  Adaption.
%    adaptwb  - By-weight-and-bias network adaption function.
% 
%  Training.
%    traingd  - Gradient descent backpropagation.
%    traingdm - Gradient descent w/momentum backpropagation.
%    traingda - Gradient descent w/adaptive lr backpropagation.
%    traingdx - Gradient descent w/momentum & adaptive lr backpropagation.
% 
%  Initialization.
%    initlay  - Layer-by-layer network initialization function.
%    initnw   - Nguyen-Widrow layer initialization function.
% 
%  Applications.
%    appelm1  - Demonstrates Elman recurrent network.

function hopfield
%MATLAB Tour Partial Function Help:  nnt_con
%
%  Hopfield recurrent networks.
%  Copyright (c) 1992-1998 by The MathWorks, Inc.
%  $Revision: 1.11 $  $Date: 1998/10/16 23:19:29 $
% 
%  New networks.
%    newhop   - Create a Hopfield recurrent network.
% 
%  Weight functions.
%    dotprod  - Dot product weight function.
% 
%  Net input functions.
%    netsum   - Sum net input function.
% 
%  Transfer functions.
%    satlins  - Symmetric saturating linear transfer function.
% 
%  Demonstrations.
%    demohop1 - Two neuron design.
%    demohop2 - Unstable equilibria.
%    demohop3 - Three neuron design.
%    demohop4 - Spurious stable points.

function linnet
%MATLAB Tour Partial Function Help:  nnt_con
%
%  Linear networks.
% 
%  New networks.
%    newlind  - Design a linear layer.
%    newlin   - Create a linear layer.
% 
%  Using networks.
%    sim      - Simulate a neural network.
%    init     - Initialize a neural network.
%    adapt    - Allow a neural network to adapt.
%    train    - Train a neural network.
% 
%  Weight functions.
%    dotprod  - Dot product weight function.
% 
%  Net input functions.
%    netsum   - Sum net input function.
% 
%  Transfer functions.
%    purelin  - Linear transfer function.
% 
%  Initialization functions.
%    initlay  - Layer-by-layer network initialization function.
%    initwb   - By-weight-and-bias layer initialization function.
%    initzero - Zero weight/bias initialization function.
% 
%  Performance.
%    mse      - Mean squared error performance function.
% 
%  Learning.
%    learnwh  - Widrow-Hoff learning rule.
% 
%  Adaption.
%    adaptwb  - By-weight-and-bias network adaption function.
% 
%  Training.
%    trainwb  - By-weight-and-bias network training function.
% 
%  Analysis functions.
%    maxlinlr - Maximum learning rate for a linear layer.
% 
%  Demonstrations and applications.
%    demolin1 - Solving for a linear network.
%    demolin2 - Training a linear neuron.
%    demolin3 - Training a linear layer.
%    demolin4 - Linear fit of nonlinear problem.
%    demolin5 - Underdetermined problem.
%    demolin6 - Linearly dependent problem.
%    demolin7 - Too large a learning rate.
%    demolin8 - Adaptive Linear Layer.
%    applin1  - Linear prediction.
%    applin2  - Adaptive linear prediction.
%    applin3  - Linear system identification.
%    applin4  - Adaptive linear system identification.
%    applin5  - Adaptive noise cancellation.

function lvq
%MATLAB Tour Partial Function Help:  nnt_con
%
%  Learning vector quantization.
% 
%  New networks.
%    newlvq   - Create a learning vector quantization network.
% 
%  Using networks.
%    sim      - Simulate a neural network.
%    init     - Initialize a neural network.
%    adapt    - Allow a neural network to adapt.
%    train    - Train a neural network.
% 
%  Weight functions.
%    negdist  - Negative distance weight function.
%    dotprod  - Dot product weight function.
% 
%  Net input functions.
%    netsum   - Sum net input function.
% 
%  Transfer functions.
%    compet   - Competitive transfer function.
%    purelin  - Linear transfer function.
% 
%  Initialization functions.
%    initlay  - Layer-by-layer network initialization function.
%    initwb   - By-weight-and-bias layer initialization function.
%    midpoint - Midpoint weight initialization function.
% 
%  Performance functions.
%    mse      - Mean squared error performance function.
% 
%  Learning functions.
%    learnlv1 - LVQ1 weight learning function.
%    learnlv2 - LVQ2 weight learning function.
% 
%  Adapt functions.
%    adaptwb  - By-weight-and-bias network adaption function.
% 
%  Training functions.
%    trainwb1 - By-weight-&-bias 1-vector-at-a-time training function.
% 
%  Demonstrations.
%    demolvq1 - Learning Vector Quantization.

function percept
%MATLAB Tour Partial Function Help:  nnt_con
%
%  Perceptrons.
% 
%  New networks.
%    newp     - Create a perceptron.
% 
%  Using networks.
%    sim      - Simulate a neural network.
%    init     - Initialize a neural network.
%    adapt    - Allow a neural network to adapt.
%    train    - Train a neural network.
% 
%  Weight functions.
%    dotprod  - Dot product weight function.
% 
%  Net input functions.
%    netsum   - Sum net input function.
% 
%  Transfer functions.
%    hardlim  - Hard limit transfer function.
%    hardlims - Symmetric hard limit transfer function.
% 
%  Initialization functions.
%    initlay  - Layer-by-layer network initialization function.
%    initwb   - By-weight-and-bias layer initialization function.
%    initzero - Zero weight/bias initialization function.
% 
%  Performance functions.
%    mae      - Mean absolute error performance function.
% 
%  Learning functions.
%    learnp   - Perceptron learning function.
%    learnpn  - Normalized perceptron learning function.
% 
%  Adapt functions.
%    adaptwb  - By-weight-and-bias network adaption function.
% 
%  Training functions.
%    trainwb  - By-weight-and-bias network training function.
% 
%  Demonstrations
%    demop1   - Classification with a 2-input perceptron.
%    demop2   - Classification with a 3-input perceptron.
%    demop3   - Classification with a 2-neuron perceptron.
%    demop4   - Outlier input vectors.
%    demop5   - Normalized perceptron rule.
%    demop6   - Linearly non-separable vectors.
%    demop7   - Classification with a two-layer perceptron.

function radbasis
%MATLAB Tour Partial Function Help:  nnt_con
%
%  Radial basis networks.
% 
%  New networks.
%    newrb    - Design a radial basis network.
%    newrbe   - Design an exact radial basis network.
%    newgrnn  - Design a generalized regression neural network.
%    newpnn   - Design a probabilistic neural network.
% 
%  Using networks.
%    sim      - Simulate a neural network.
% 
%  Weight functions.
%    dist     - Euclidean distance weight function.
%    dotprod  - Dot product weight function.
%    normprod - Normalized dot product weight function.
% 
%  Net input functions.
%    netprod  - Product net input function.
%    netsum   - Sum net input function.
% 
%  Transfer functions.
%    compet   - Competitive transfer function.
%    purelin  - Hard limit transfer function.
%    radbas   - Radial basis transfer function.
% 
%  Performance.
%    mse      - Mean squared error performance function.
% 
%  Signals.
%    ind2vec  - Convert indices to vectors.
%    vec2ind  - Convert vectors to indices.
% 
%  Demonstrations.
%    demorb1  - Function approximation with a radial basis network.
%    demorb2  - Benchmarking function approximators.
%    demorb3  - Underlapping neurons.
%    demorb4  - Overlapping neurons.
% 	demopnn1 - Probabilistic neural network classification.
%    demogrn1 - Generalized regression neural network approximation.

function selforg
%MATLAB Tour Partial Function Help:  nnt_con
%
%  Self-organizing networks.
% 
%  New networks.
%    newc     - Create a competitive layer.
% 	newsom   - Create a self-organizing map.
% 
%  Using networks.
%    sim      - Simulate a neural network.
%    init     - Initialize a neural network.
%    adapt    - Allow a neural network to adapt.
%    train    - Train a neural network.
% 
%  Weight functions.
%    negdist  - Dot product weight function.
% 
%  Net input functions.
%    netsum   - Sum net input function.
% 
%  Transfer functions.
%    compet   - Competitive transfer function.
% 
%  Topology functions.
%    gridtop  - Grid layer topology function.
%    hextop   - Hexagonal layer topology function.
%    randtop  - Random layer topology function.
% 
%  Distance functions.
%    dist     - Euclidean distance weight function.
%    mandist  - Manhattan distance weight function.
%    linkdist - Link distance function.
% 
%  Initialization functions.
%    initlay  - Layer-by-layer network initialization function.
%    initwb   - By-weight-and-bias layer initialization function.
%    initcon  - Conscience bias initialization function.
%    midpoint - Midpoint weight initialization function.
% 
%  Learning functions.
%    learnk   - Kohonen weight learning function.
%    learncon - Conscience bias learning function.
%    learnsom - Self-organizing map weight learning function.
% 
%  Adapt functions.
%    adaptwb  - By-weight-and-bias network adaption function.
% 
%  Training functions.
%    trainwb1 - By-weight-&-bias 1-vector-at-a-time training function.
% 
%  Plotting.
%    plotsom  - Plot self-organizing map.
% 
%  Demonstrations.
%    democ1   - Competitive learning.
%    democ2   - Input vector distribution.
%    demosm1  - 1-dimensional self-organizing map.
%    demosm2  - 2-dimensional self-organizing map.

function demop1
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demop1', 

function demop4
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demop4', 

function demop5
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demop5', 

function demop6
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demop6', 

function demolin1
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demolin1', 

function demolin2
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demolin2', 

function demolin4
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demolin4', 

function demolin5
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demolin5', 

function demolin6
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demolin6', 

function demolin7
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demolin7', 

function demolin8
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demolin8', 

function demorb1
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demorb1', 

function demorb3
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demorb3', 

function demorb4
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demorb4', 

function demogrn1
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demogrn1', 

function demopnn1
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demopnn1', 

function democ1
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow democ1', 

function demosm1
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demosm1', 

function demosm2
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demosm2', 

function demolvq1
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demolvq1', 

function demohop1
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demohop1', 

function demohop2
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demohop2', 

function demohop3
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demohop3', 

function demohop4
%MATLAB Tour Partial Function Help:  nnt_con
%
%  This is a slideshow file for use with playshow.m and makeshow.m
%  To see it run, type 'playshow demohop4', 

function applin1
%MATLAB Tour Partial Function Help:  nnt_con
%
% APPLIN1 Linear prediction.

function applin2
%MATLAB Tour Partial Function Help:  nnt_con
%
% APPLIN2 Adaptive linear prediction.

function applin3
%MATLAB Tour Partial Function Help:  nnt_con
%
% APPLIN3 Linear system identification.

function applin4
%MATLAB Tour Partial Function Help:  nnt_con
%
% APPLIN4 Adaptive linear system identification.

function appelm1
%MATLAB Tour Partial Function Help:  nnt_con
%
% DEMOELM1 Demonstrates Elman recurrent network.

function appcs1
%MATLAB Tour Partial Function Help:  nnt_con
%
% APPCS1 Nonlinear system identification.

function appcs2
%MATLAB Tour Partial Function Help:  nnt_con
%
% APPCS2 Feedback linearization.

function appcr1
%MATLAB Tour Partial Function Help:  nnt_con
%
% APPCR1 Character recognition.

function nnd
%MATLAB Tour Partial Function Help:  nnt_con
%
%  NND Neural Network Design graphical user interface.

function nndtoc
%MATLAB Tour Partial Function Help:  nnt_con
%
%  NNDTOC Neural Network Design table of contents.

function nnsound
%MATLAB Tour Partial Function Help:  nnt_con
%
% NNSOUND Turn Neural Network Design sounds on and off.
% 
% 	NNSOUND OFF turns off demo sounds.
% 	  Use this to avoid annoying co-workers and to speed up
% 	  demos with lots of sound.
% 
% 	NNSOUND ON turns them back on.
% 	  Use this when you to experience quadraphonic digitally
% 	  enhanced audio entertainment and you don't care who
% 	  knows it.
% 
% 	Regardless of the settings described above, sound is always
% 	off for the Student Edition of MATLAB.

function nnd2n1
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND2N1 One-input neuron demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd2n2
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND2N2 Two-input neuron demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd3pc
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND3PC Perceptron classification demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd3hamc
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND3HAMC Hamming classification demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd3hopc
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND3HOPC Hopfield classification demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd4db
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND4DB Decision boundaries demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd4pr
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND4PR Perceptron rule demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd5gs
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND5GS Gram-Schmidt demonstration.

function nnd5rb
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND5RB Reciprocal basis demonstration.

function nnd6lt
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND6LT Linear transformations demonstration.

function nnd6eg
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND6EG Eigenvector game.

function nnd7sh
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND7SH Supervised Hebb demonstration.

function nnd8ts1
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND8TS Taylor series demonstration #1.

function nnd8ts2
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND8TS2 Taylor series demonstration #2.

function nnd8dd
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND8DD Directional derivatives demonstration.

function nnd8qf
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND8QF Quadratic function demonstration.

function nnd9sdq
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND9SDQ Steepest descent for quadratic function demonstration.

function nnd9mc
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND9MC Method comparison demonstration.

function nnd9nm
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND9NM Newton's method demonstration.

function nnd9sd
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND9SD Steepest descent demonstration.

function nnd10nc
%MATLAB Tour Partial Function Help:  nnt_con
%
%  NND10NC Adaptive noise cancellation demonstration.

function nnd10eeg
%MATLAB Tour Partial Function Help:  nnt_con
%
%  NND10EEG Electroencephalogram noise cancellation demonstration.

function nnd10lc
%MATLAB Tour Partial Function Help:  nnt_con
%
%  NND10LC Linear pattern classification demonstration.

function nnd11nf
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND11NF Network function demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.
% 
% 	NND11NF
% 	Opens demonstration with default values.
% 
% 	NND11NF('set',W1,b1,W2,b2,f2)
% 	  W1 - 2x1 weight matrix for 1st layer.
% 	  b1 - 2x1 bias vector for 1st layer.
% 	  W2 - 1x2 weight matrix for 2nd layer.
% 	  b2 - 1x1 bias for 2nd layer.
% 	  f2 - Name (string) of 2nd layer transfer function.
% 	Sets network parameters accordingly.
% 
% 	NND11NF('random')
% 	Sets network parameters to randomly chosen values.
% 
%  [W1,b1,W2,b2,f2] = NND11NF('get')
% 	Gets network parameters.

function nnd11bc
%MATLAB Tour Partial Function Help:  nnt_con
%
%  NND11BC Backpropagation calculation demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.
% 
% 	NND11BC runs this demo.
% 
% 	NND11BC('set',W1,b1,W2,b2)
% 	  sets the network's weight and bias values.
% 
% 	[W1,b1,W2,b2] = NND11BC('get')
% 	  gets the network's weight and bias values.

function nnd11fa
%MATLAB Tour Partial Function Help:  nnt_con
%
%  NND11FA Function approximation demonstration.
%  This demonstration requires the Neural Network Toolbox.

function nnd11gn
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND11GN Generalization demonstration.
% 	This demonstration requires the Neural Network Toolbox.

function nnd12sd1
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND12SD1 Steepest descent backpropagation demonstration #1.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd12sd2
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND12SD2 Steepest descent backpropagation demonstration #2.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd12mo
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND12MO Momentum backpropagation demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd12vl
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND12VL Variable learning rate backpropagation demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd12ls
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND12LS Conjugate gradient lines search demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd12cg
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND12CG Conjugate gradient backpropagation demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd12ms
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND12MS Marquardt step demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd12m
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND12M Marquardt backpropagation demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd13uh
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND13UH Unsupervised Hebb demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd13edr
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND13EDR Effects of decay rate demonstration.

function nnd13hd
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND13HD Hebb with decay demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd13gis
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND13GIS Graphical instar demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd13is
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND13IS Instar demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd13os
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND13OS Unsupervised Hebb demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd14cc
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND14CC Competitive classification demonstration.
% 
% 	This demonstration requires either the MININNET functions
% 	on the NND disk or the Neural Network Toolbox.

function nnd14cl
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND14CL Competitive learning demonstration.
% 
% 	This demonstration requires either the MININNET functions
%  	on the NND disk or the Neural Network Toolbox.

function nnd14fm1
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND14FM1 1-D feature map demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd14fm2
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND14FM2 2-D feature map demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd14lv1
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND4LV1 LVQ1 demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd14lv2
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND4LV1 LVQ2 demonstration.
% 
% 	This demonstration requires the Neural Network Toolbox.

function nnd15li
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND15LI Leaky integrator demonstration.

function nnd15sn
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND15SN Shunting network demonstration.

function nnd15gl1
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND15GL1 Grossberg layer 1 demonstration.

function nnd15gl2
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND15GL2 Grossberg layer 2 demonstration.

function nnd15aw
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND15AW Adaptive weights demonstration.

function nnd16al1
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND16AL1 ART1 layer 1 demonstration.

function nnd16al2
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND16AL2 ART1 layer 2 demonstration.

function nnd16os
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND16OS Orienting subsystem demonstration.

function nnd16a1
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND16A1 ART1 algorithm demonstration.

function nnd17ds
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND17DS Dynamical system demonstration.

function nnd18hn
%MATLAB Tour Partial Function Help:  nnt_con
%
% NND18HN Hopfield network demonstration.

function mytf
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYTF Example custom transfer function.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Calculation Syntax
% 
% 	  A = mytf(N)
% 	    N - SxQ matrix of Q net input (column) vectors.
% 	    A - SxQ matrix of Q output (column) vectors.
% 
% 	Information Syntax
% 
% 	  info = mytf(code) returns useful information for each CODE string:
% 	    'version' - Returns the Neural Network Toolbox version (3.0).
% 	    'deriv'   - Returns the name of the associated derivative function.
% 	    'output'  - Returns the output range.
% 	    'active'  - Returns the active input range.
% 
% 	Example
% 
% 	  n = -5:.1:5;
% 	  a = mytf(n);
% 	  plot(n,a)
%  $Revision: 1.11 $

function mydtf
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYDTF Example custom transfer derivative function of MYTF.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Syntax
% 
% 	  dA_dN = mydtf(N,A)
% 	    N - SxQ matrix of Q net input (column) vectors.
% 	    A - SxQ matrix of Q output (column) vectors.
% 	    dA_dN - SxQ derivative dA/dN.
% 
% 	Example
% 
% 	  n = -5:.1:5;
% 	  a = mytf(n);
% 	  da_dn = mydtf(n,a);
% 	  subplot(2,1,1), plot(n,a)
% 	  subplot(2,1,2), plot(n,da_dn)
%  $Revision: 1.11 $

function mynif
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYNIF Example custom net input function.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Calculation Syntax
% 
% 	  N = mynif(Z1,Z2,...)
% 	    Zi - SxQ matrix of Q weighted (column) vectors.
% 	    N - SxQ matrix of Q net input (column) vectors.
% 
% 	Information Syntax
% 
% 	  info = mynif(code) returns useful information for each CODE string:
% 	    'version' - Returns the Neural Network Toolbox version (3.0).
% 	    'deriv'   - Returns the name of the associated derivative function.
% 
% 	Example
% 
% 	  z1 = rand(4,5);
% 	  z2 = rand(4,5);
% 	  z3 = rand(4,5);
% 	  n = mynif(z1,z2,z3)
%  $Revision: 1.11 $

function mydnif
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYDNIF Example custom net input derivative function of MYNIF.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Syntax
% 
% 	  dN_dZ = dtansig(Z,N)
% 	    Z - SxQ matrix of Q weighted input (column) vectors.
% 	    N - SxQ matrix of Q net input (column) vectors.
% 	    dN_dZ - SxQ derivative dN/dZ.
% 
% 	Example
% 
% 	  z1 = rand(4,5);
% 	  z2 = rand(4,5);
% 	  z3 = rand(4,5);
% 	  n = mynif(z1,z2,z3)
% 	  dn_dz1 = mydnif(z1,n)
% 	  dn_dz2 = mydnif(z2,n)
% 	  dn_dz3 = mydnif(z3,n)
%  $Revision: 1.11 $

function mywf
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYWF Example custom weight function.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Calculation Syntax
% 
% 	  Z = mywf(W,P)
% 	    W - SxR weight matrix.
% 	    P - RxQ matrix of Q input (column) vectors.
% 	    Z - SxQ matrix of Q weighted input (column) vectors.
% 
% 	Information Syntax
% 
% 	  info = mytf(code) returns useful information for each CODE string:
% 	    'version' - Returns the Neural Network Toolbox version (3.0).
% 	    'deriv'   - Returns the name of the associated derivative function.
% 
% 	Example
% 
% 	  w = rand(1,5);
% 	  p = rand(5,1);
% 	  z = mywf(w,p)
%  $Revision: 1.11 $

function mydwf
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYDWF Example custom weight derivative function for MYWF.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Syntax
% 
% 	  dZ_dP = mydwf('p',W,P,Z)
% 	  dZ_dW = mydwf('w',W,P,Z)
% 	    W - SxR weight matrix.
% 	    P - RxQ matrix of Q input (column) vectors.
% 	    Z - SxQ matrix of Q weighted input (column) vectors.
% 	    dZ_dP - SxR derivative dZ/dP.
% 	    dZ_dW - RxQ derivative dZ/dW.
% 
% 	Example
% 
% 	  w = rand(1,5);
% 	  p = rand(5,1);
% 	  z = mywf(w,p)
% 	  dz_dp = mydwf('p',w,p,z)
% 	  dz_dw = mydwf('w',w,p,z)
%  $Revision: 1.11 $

function mywbif
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYWBIF Example custom weight and bias initialization function.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Syntax
% 
% 	  W = rands(S,PR)
% 	    S  - number of neurons.
% 	    PR - Rx2 matrix of R input ranges.
% 	    W - SxR weight matrix.
% 
% 	  b = rands(S)
% 	    S  - number of neurons.
% 	    b - Sx1 bias vector.
% 
% 	Example
% 
% 	  W = mywbif(4,[0 1; -2 2])
% 	  b = mywbif(4,[1 1])
%  $Revision: 1.11 $

function mypf
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYPF Example custom performance function.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Calculation Syntax
% 
% 	  perf = mypf(E,X,PP)
% 	    E  - Matrix or cell array of error vector(s).
% 	    X  - Vector of all weight and bias values.
% 	    PP - Performance parameter.
% 
% 	  perf = mypf(E,net)
% 
% 	Information Syntax
% 
% 	  info = mytf(code) returns useful information for each CODE string:
% 	    'version' - Returns the Neural Network Toolbox version (3.0).
% 	    'deriv'   - Returns the name of the associated derivative function.
% 	    'output'  - Returns the output range.
% 	    'active'  - Returns the active input range.
% 
% 	Example
% 
% 	  e = rand(4,5);
% 	  x = rand(12,1);
% 	  pp = mypf('pdefaults')
% 	  perf = mypf(e,x,pp)
%  $Revision: 1.11 $

function mydpf
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYDPF Example custom performance derivative function for MYPF.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Syntax
% 
% 	  dPerf_dE = mydpf('e',E,X,perf,PP)
% 	  dPerf_dX = mydpf('x',E,X,perf,PP)
% 	    E  - Cell array of error vector(s).
% 	    X  - Vector of all weight and bias values.
% 	    PP - Performance parameters.
% 	    dPerf_dE - Cell array of derivative of performance dPerf/dE.
% 	    dPerf_dX - Derivative of performance dPerf/dX.
% 
% 	Example
% 
% 	  e = {rand(4,5)};
% 	  x = rand(12,1);
% 	  pp = mypf('pdefaults')
% 	  perf = mypf(e,x,pp)
% 	  dperf_de = mydpf('e',e,x,perf,pp)
% 	  dperf_dx = mydpf('x',e,x,perf,pp)
%  $Revision: 1.11 $

function mywblf
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYWBLF Example custom weight and bias learning function.
% 	
% 	Calculation Syntax
% 	
% 	  [dW,LS] = mywblf(W,P,Z,N,A,T,E,gW,gA,D,LP,LS)
% 	  [db,LS] = mywblf(b,ones(1,Q),Z,N,A,T,E,gW,gA,D,LP,LS)
% 	    W  - SxR weight matrix (or Sx1 bias vector).
% 	    P  - RxQ input vectors (or ones(1,Q)).
% 	    Z  - SxQ weighted input vectors.
% 	    N  - SxQ net input vectors.
% 	    A  - SxQ output vectors.
% 	    T  - SxQ layer target vectors.
% 	    E  - SxQ layer error vectors.
% 	    gW - SxR gradient with respect to performance.
% 	    gA - SxQ output gradient with respect to performance.
% 	    D  - SxS neuron distances.
% 	    LP - Learning parameters, none, LP = [].
% 	    LS - Learning state, initially should be = [].
% 	    dW - SxR weight (or bias) change matrix.
% 
% 	Information Syntax
% 
% 	  info = mywblf(code) returns useful information for each CODE string:
% 	    'version'   - Returns the Neural Network Toolbox version (3.0).
% 	    'pdefaults' - Returns the name of the associated derivative function.
% 	    'needg'     - Returns the output range.
% 
% 	Example
% 
% 	  W = rand(4,5);
% 	  gW = rand(4,5);
% 	  lp = mywblf('pdefaults')
% 	  [dW,ls] = mywblf(w,[],[],[],[],[],[],gW,[],[],lp,[]);
% 	  W = W + dW;
% 	  gW = rand(4,5);
% 	  [dW,ls] = mywblf(w,[],[],[],[],[],[],gW,[],[],lp,ls);
% 	  W = W + dW;
%  $Revision: 1.11 $

function mydistf
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYDISTF Example custom distance function.
% 
% 	Use this function as a template to write your own function.
% 	
%      Syntax
% 
% 	  d = mydistf(pos)
% 	    pos - NxS matrix of S neuron position vectors.
% 	    d   - SxS matrix of neuron distances.
% 
% 	Example
% 
% 	  pos = gridtop(3,2);
% 	  d = mydistf(pos)
%  $Revision: 1.11 $

function mytopf
%MATLAB Tour Partial Function Help:  nnt_con
%
% MYTOPF Example custom topology function.
% 
% 	Use this function as a template to write your own function.
% 	
% 	Syntax
% 
% 	  pos = mytopf(dim1,dim2,...,dimN)
% 	    dimi - number of neurons along the ith layer dimension
% 	    pos  - NxS matrix of S position vectors, where S is the
% 	           total number of neurons which is defined by the
% 	            product dim1*dim1*...*dimN.
% 
% 	Example
% 
% 	  pos = mytopf(20,20);
% 	  plotsom(pos)
%  $Revision: 1.11 $

