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

📄 hopf.m

📁 我编写hopf的神经网络应用程序
💻 M
字号:
%Example 3.26
%
clf;
figure(gcf)
setfsize(300,300);
echo on
clc
%    NewHOP  - 设计Hopfield网络
%    SIM   - 对Hopfield网络进行仿真
pause % Strike any key to define the problem...
clc
T = [+1 +1;
     -1 +1;
     -1 -1];
plot3(T(1,:),T(2,:),T(3,:),'r*')
axis([-1 1 -1 1 -1 1])
xlabel('a(1)')
ylabel('a(2)')
zlabel('a(3)')
title('Hopfield Network state Space')
set(gca,'box','on')
view([37.5 30])
pause % Strike any key to design the network...
clc
net=newhop(T);
net.lw{1,1}
net.b{1}
pause % Strike any key to simulate the network...
clc
a={rands(3,1)};
aa=sim(net,{1 50},[],a);
aa=[cell2mat(a) cell2mat(aa)];
hold on
plot3(aa(1,1),aa(2,1),aa(3,1),'kx',aa(1,:),aa(2,:),aa(3,:))
pause % Strike any key to simulate the network some more...
clc
hold on
color = 'rgbmy';
for i=1:5
  a = {rands(3,1)};
  aa=sim(net,{1,20},[],a);
  aa=[cell2mat(a) cell2mat(aa)];  
  plot3(aa(1,1),aa(2,1),aa(3,1),'kx',aa(1,:),aa(2,:),aa(3,:),color(i))
  drawnow
end
pause % Strike any key to see more simulations...
clc
P = [ 1.0  -1.0  -0.5  1.00  1.00  0.0;
      0.0   0.0   0.0  0.00  0.01 -0.2;
     -1.0   1.0   0.5 -1.01 -1.00  0.0]
%hold off
echo off
for i=1:6
   a = {P(:,i)};
   [s,q]=size(a);
  aa=sim(net,{q 100},[],a);
  aa=[cell2mat(a) cell2mat(aa)];
  plot3(T(1,:),T(2,:),T(3,:),'r*',aa(1,1),aa(2,1),aa(3,1),'kx', ...
        aa(1,:),aa(2,:),aa(3,:),'g',aa(1,101),aa(2,101),aa(3,101),'o')
  axis([-1.1 1.1 -1.1 1.1 -1.1 1.1])
  xlabel('a(1)')
  ylabel('a(2)')
  zlabel('a(3)')
  title('Hopfield Network State Space')
  set(gca,'box','on')
  view([37.5 30])
  pause
end
echo on

⌨️ 快捷键说明

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