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

    bounds = [0 1; 0 1];   % 设定边界
clusters = 8;          % 设定簇的数量.
points = 10;           % 设定每个簇的点数.
std_dev = 0.05;        % 每个簇的标准偏差.
x = nngenc(bounds,clusters,points,std_dev);%创建输入向量X.

% 绘制输入向量X.
plot(x(1,:),x(2,:),'+r');
title('Input Vectors');
xlabel('x(1)');
ylabel('x(2)');


net = competlayer(8,.1);
net = configure(net,x);
w = net.IW{1};
plot(x(1,:),x(2,:),'+r');
hold on;
circles = plot(w(:,1),w(:,2),'ob');

net.trainParam.epochs = 7;
net = train(net,x);
w = net.IW{1};
delete(circles);
plot(w(:,1),w(:,2),'ob');

x1 = [0; 0.2];
y = net(x1)