www.gusucode.com > 《MATLAB神经网络仿真与应用》[张德丰]的所有[程序源代码] > 第3章/li3_4.m

    P=[0.1 0.8 0.1 0.9;0.2 0.9 0.1 0.8];
net=newsom([0 2;0 1],[3 5]);
plotsom(net.layers{1}.positions)
%进行训练
%训练次数为10
net.trainParam.epochs=10;
net=train(net,P);
plot(P(1,:),P(2,:),'.g','markersize',20);
hold on;
%绘制训练后神经元的位置
plotsom(net.iw{1,1},net.layers{1}.distances);
hold off;
figure;
%训练次数为25
%训练前进行初始化
net=init(net);
net.trainParam.epochs=25;
net=train(net,P);
plot(P(1,:),P(2,:),'.g','markersize',20);
hold on;
plotsom(net.iw{1,1},net.layers{1}.distances);
hold off;