⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p5.54.txt

📁 Matlab_Network_and_Application是国防工业出版社董长虹编著《神经网络与应用》的课本源码。
💻 TXT
字号:
%输入和期望
P=[1 2;2 2;1 1]';
Tc=[1 2 3];
%显示输入向量
plot(P(1,:),P(2,:),'.','markersize',30)
%显示对应类别
for i=1:3,text(P(1,i)+0.1,P(2,i),sprintf('class %g',Tc(i))),end
axis([0 3 0 3])
title('三向量及其类别');
xlabel('P(1,:)');
ylabel('T(2,:)');
%网络设计
T=ind2vec(Tc);
spread=1;
net=newgrnn(P,T,spread);
%验证
A=sim(net,P);
Ac=vec2ind(A);
%显示
plot(P(1,:),P(2,:),'.','markersize',30)
axis([0 3 0 3])
for i=1:3,text(P(1,i)+0.1,P(2,i),sprintf('class %g',Ac(i))),end
title('网络测试结果');
xlabel('P(1,:)');
ylabel('P(2,:)');
%仿真
p=[2;1.5];
a=sim(net,p);
ac=vec2ind(a);
hold on
plot(p(1),p(2),'*','markersize',10,'color',[1 0 0])
text(p(1)+0.1,p(2),sprintf('class %g',ac))
hold off;
title('对新向量分类');
xlabel('P(1,:)和p(1)');
ylabel('P(2,:)和p(2)');
%显示三个向量所在面
p1=0:.05:3;
p2=p1;
%为三维图产生矩阵
[p1,p2]=meshgrid(p1,p2);
pp=[p1(:) p2(:)]';
%仿真
aa=sim(net,pp);
aa=full(aa);
%mesh网图,reshape改造矩阵,显示(同一图显示)
m=mesh(p1,p2,reshape(aa(1,:),length(p1),length(p2)));
set(m,'facecolor',[0 0.5 1],'linestyle','none');
hold onm=mesh(p1,p2,reshape(aa(2,:),length(p1),length(p2)));
set(m,'facecolor',[0 1 0.5],'linestyle','none');
m=mesh(p1,p2,reshape(aa(3,:),length(p1),length(p2)));
set(m,'facecolor',[0.5 0 1],'linestyle','none');
%绘制点
plot3(P(1,:),P(2,:),[1 1 1]+0.1,'.','markersize',30)
plot3(p(1),p(2),1.1,'*','markersize',10,'color',[1 0 0])
hold off
view(2)
title('向量立体分布');
xlabel('P(1,:)和p(1)');
ylabel('p(2,:)和p(2)');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -