% % % Reference webpage:[Link]
com/help/nnet/ug/create-and-
[Link]
% % % Reference webpage:[Link]
[Link]
input_peri(1,:)=[1:36];
input_peri(2,:)=[37:72];
input_peri(3,:)=[8:43];
input_peri(4,:)=[12:47];
output_peri(1,:)=[0:35];
tic
% % % Creating the network named net
net=network;
% % % Specifying number of input vectors in the network
[Link]=4;
% % % Specifying number of layers in the network
[Link]=2;
% % % Specifying that bias is connected to both first and second layer
[Link](1)=1;
[Link](2)=1;
% % % Specifying first to fourth input vectors are connected to layer one
[Link](1,1)=1;
[Link](1,2)=1;
[Link](1,3)=1;
[Link](1,4)=1;
% % % Specifying output of first (hidden) layer are connected to input of 2nd
layer
[Link](2,1)=1;
% % % Specifying second layer is connected to output
[Link]=[0 1];
% % % Specifying values and preprocessed functions to each four input
% % % vectors. These are taken to be removeconstantrows and mapminmax for all
% % % for vectors.
% % % % % First input vector comprise distance of all intersecting points
from
% % % neutral axis. Second input vector is distance of all intersecting
points
% % % from centroid. Third input vector comprises values of normal strain at
% % % all intersecting points. Fourth input vector comprises values of shear
% % % strain at all intersecting points. These inputs are for periosteal
% % % surface only
[Link]{1}.exampleInput = input_peri(1,:);
[Link]{1}.processFcns = {'removeconstantrows','mapminmax'};
[Link]{2}.exampleInput = input_peri(2,:);
[Link]{2}.processFcns = {'removeconstantrows','mapminmax'};
[Link]{3}.exampleInput = input_peri(3,:);
[Link]{3}.processFcns = {'removeconstantrows','mapminmax'};
[Link]{4}.exampleInput = input_peri(4,:);
[Link]{4}.processFcns = {'removeconstantrows','mapminmax'};
% % Specifying number of neurons in first layer
[Link]{1}.size = 5;
% % % Specifying transfer function for first layer
[Link]{1}.transferFcn = 'tansig';
% % % Specifying initialization function of weights and biases for first
layer
[Link]{1}.initFcn = 'initnw';
% % % Specifying number of neurons in second layer
[Link]{2}.size =1;
% % % Specifying transfer function for second layer
[Link]{2}.transferFcn = 'purelin';
% % % Specifying initialization function of weights and biases for second
layer
[Link]{2}.initFcn = 'initnw';
% % % Specifying output vector and its preprocessed functions
[Link]{2}.exampleOutput = output_peri(1,:);
[Link]{2}.processFcns = {'removeconstantrows','mapminmax'};
%
% % % Set the initialization function to initlay so the network
% % % initializes itself according to the layer initialization functions
% % % already set to initnw
[Link] = 'initlay';
%
% % % % Dividing data randomly
[Link] = 'dividerand';
[Link] = 'sample'; % Divide up every sample
[Link] = 97/100;
[Link] = 0/100;
[Link] = 3/100;
% % % % Set the performance function to mse (mean squared error) and
% % % % the training function to trainlm (Levenberg-Marquardt
backpropagation)
% % % % to meet the final requirement of the custom network
[Link] = 'mse';
[Link] = 'trainlm';
% % % % Set the plot functions to plotperform (plot training, validation
% % % % and test performance) and plottrainstate (plot the state of the
training
% % % % algorithm with respect to epochs).
[Link] =
{'plotperform','plottrainstate','ploterrhist','plotregression', 'plotfit'};
% % % % Initializing the network
net = init(net);
X=[input_peri(1,:);input_peri(2,:);input_peri(3,:);input_peri(4,:)];
T=output_peri(1,:);
net = train(net,X,T);
Y=sim(net,X)
net
view(net)
error=Y-T
plot(Y,T)
toc