gusucode.com > 《MATLAB神经网络超级学习手册》随书光盘源码程序 > code/5/N5_7.m

    clear all
clc
P=[0.5 -1 2;-0.8 1.3 1];
T=[1 1 0];
net=newp([-1 1;-1 1],1);       %建立单层感知器神经网络
h=plotpc(net.iw{1},net.b{1});  %返回画线的句柄
net.trainParam.epochs=50;      %设置训练次数最大为50
net=train(net,P,T);            %训练神经网络
%%%%%%%%%用训练后的感知器网络仿真%%%%%%%%%%%%
M=[0.5 1.1 -0.2;-0.2 -0.6 0.6];
Y=sim(net,M);
figure
plotpv(M,Y);                   %绘制分界线
h=plotpc(net.iw{1},net.b{1},h)