%% Sample Data: [x,t]=simplefit_dataset; %% Initialize, train the 1-10-1 network: net=feedforwardnet(10); net=train(net,x,t); %% Get some new data, then manually apply the network to the data: xx=linspace(min(x),max(x),100); % By default, Matlab scales the data. We are using the parameters from the % neural network and applying the same scaling to the new incoming data: xa=mapminmax('apply',xx,net.input.processSettings{1}); % Here are the two sets of weights and biases: W1=net.IW{1,1}; b1=net.b{1}; W2=net.LW{2,1}; b2=net.b{2}; % First prestate: P1=W1*xa+repmat(b1,1,100); % First state: S1=tansig(P1); % Second prestate (output layer, so state=prestate here) P2=W2*S1+b2; Y=mapminmax('reverse',P2,net.outputs{2}.processSettings{1}); % Plot: plot(x,t,'.',xx,Y,'r-')