%% Sample Training Session %Create some artificial data P=linspace(-2,2,50); T=sin(pi*P)+0.2*randn(size(P)); % We'll build a 1-15-1 network and train it: net=feedforwardnet(5); %10 nodes in hidden layer net=configure(net,P,T); % Initialize weights and biases y1=sim(net,P); % Just for fun (randomly assigned weights) % Training: net=train(net,P,T); %Training command y2=sim(net,P); % Network output after training %% See how the network performs with new data tt=linspace(-2,2,200); yy=sim(net,tt); %% Compare to the noise-free model yModel=sin(pi*tt); plot(P,T,'o',P,y1,'b-',tt,yy,'k-',tt,yModel,'r-'); legend('Data','Output 1','Output 2','No Noise');