% function netc1
% m file, ndtc1.m, as a function for the custom neural network example
% define the name netc1 as a neural network RWN 02/18/08 
netc1 = network;
% fix the number of inputs and layers
netc1.numInputs = 2;
netc1.numLayers = 3;
% fix the connections
netc1.biasConnect(1) = 1;
netc1.biasConnect(3) = 1;
netc1.inputConnect(1,1) = 1;
netc1.inputConnect(2,1) = 1;
netc1.inputConnect(2,2) = 1;
netc1.layerConnect = [0 0 0; 0 0 0; 1 1 1];
netc1.outputConnect = [0 1 1];
netc1.targetConnect = [0 0 1];
% input information
netc1.inputs{1}.range = [0 10; 0 10];
netc1.inputs{2}.range = [-2 2; -2 2; -2 2; -2 2; -2 2];
% set layer sizes and nature; layer 3 size is set by default
netc1.layers{1}.size = 4;
netc1.layers{1}.transferFcn = 'tansig';
netc1.layers{1}.initFcn = 'initnw';
netc1.layers{2}.size = 3;
netc1.layers{2}.transferFcn = 'logsig';
netc1.layers{2}.initFcn = 'initnw';
netc1.layers{3}.initFcn = 'initnw';
% set delays 
netc1.inputWeights{2,1}.delays = [0 1];
% netc1.inputWeights{2,1}.delays = [1 2];
% netc1.inputWeights{2,2}.delays = 6;
netc1.inputWeights{2,2}.delays = 1;
netc1.layerWeights{3,3}.delays = 1;
% set initialization, performance and training information
netc1.initFcn = 'initlay';
netc1.performFcn = 'mse';
netc1.trainFcn = 'trainlm';
% initialization
netc1 = init(netc1)
% training set up
netc1.trainParam.goal = 1e-10;
% input data
P = {[0; 0] [2; 0.5]; [2; -2; 1; 0; 1] [-1; -1; 1; 0; 1]}
% desired output for input P
T = {1 -1}
% perform a simulation
Yc1 = sim(netc1,P)
netc2 = train(netc1,P,T);
