function slide=demohop3
% This is a slideshow file for use with playshow.m and makeshow.m
% To see it run, type 'playshow demohop3', 

% Copyright (c) 1992-1998 by The MathWorks, Inc.
% $Revision: 1.12 $  $Date: 1998/06/11 16:23:40 $

if nargout<1,
  playshow demohop3
else
  %========== Slide 1 ==========

  slide(1).code={
   'slideData=nnslides(''start'',slideData'',''A Three Neuron Hopfield Network'');',
   '' };
  slide(1).text={
   'NEWHOP  - Creates a Hopfield network.',
   'SIM   - Simulates a neural  network.',
   '',
   'A Hopfield network is designed with target stable points. The behavior of the Hopfield network for different initial conditions is studied.',
   ''};

  %========== Slide 2 ==========

  slide(2).code={
   'slideData=nnslides(''blank'',slideData);',
   'cla;',
   ' T = [+1 +1;  -1 +1;      -1 -1];',
   '' };
  slide(2).text={
   ' We would like to obtain a Hopfield network that has the two stable points defined by the two target (column) vectors in T.',
   '>> T = [+1 +1;',
   '              -1 +1;',
   '              -1 -1];',
   '',
   '',
   ''};

  %========== Slide 3 ==========

  slide(3).code={
   'slideData=nnslides(''axes'',slideData);',
   'cla;',
   'axis([-1 1 -1 1 -1 1])',
   'set(gca,''box'',''on''); axis manual;  hold on;',
   'plot3(T(1,:),T(2,:),T(3,:),''r*'')',
   'title(''Hopfield Network State Space'')',
   'xlabel(''a(1)'');',
   'ylabel(''a(2)'');',
   'zlabel(''a(3)'');',
   'view([37.5 30]);' };
  slide(3).text={
   'Here is a plot where the stable points are shown at the corners.  All possible states of the 2-neuron Hopfield network are contained within the plots boundaries.',
   '>> plot3(T(1,:),T(2,:),T(3,:),''r*'')',
   '>> axis([-1 1 -1 1 -1 1]); axis manual;  hold on;',
   '>> title(''Hopfield Network State Space'')',
   '>> xlabel(''a(1)''); ylabel(''a(2)''); zlabel(''a(3)'');',
   '>> set(gca,''box'',''on'');  view([37.5 30]);'};

  %========== Slide 4 ==========

  slide(4).code={
   '',
   ' net=newhop(T);' };
  slide(4).text={
   'The function NEWHOP creates Hopfield networks given the stable points T.',
   '>> net=newhop(T);',
   ''};

  %========== Slide 5 ==========

  slide(5).code={
   'cla;',
   'a = {rands(3,1)};',
   '[y,Pf,Af] = sim(net,{1 10},{},a);' };
  slide(5).text={
   'Here we define a random starting point and simulate the Hopfield network for 50 steps. It should reach one of its stable points.',
   '',
   '>> a = {rands(3,1)};',
   '>> [y,Pf,Af] = sim(net,{1 10},{},a);',
   ''};

  %========== Slide 6 ==========

  slide(6).code={
   'cla;',
   'plot3(T(1,:),T(2,:),T(3,:),''r*'')',
   'record=[cell2mat(a) cell2mat(y)];',
   'start=cell2mat(a);',
   'plot3(start(1,1),start(2,1),start(3,1),''bx'',record(1,:),record(2,:),record(3,:))' };
  slide(6).text={
   'We can make a plot of the Hopfield networks activity.',
   '>> record=[cell2mat(a) cell2mat(y)];',
   '>> start=cell2mat(a);',
   '>> hold on',
   '>> plot3(start(1,1),start(2,1),start(3,1),''bx'',record(1,:),record(2,:),record(3,:))',
   '',
   'Sure enough, the network ends up at a designed stable point in the corner.'};

  %========== Slide 7 ==========

  slide(7).code={
   'slideData=nnslides(''lock'',slideData);',
   'cla;',
   'plot3(T(1,:),T(2,:),T(3,:),''r*'')',
   'color = ''rgbmy'';',
   'for i=1:25',
   'a = {rands(3,1)};    [y,Pf,Af] = sim(net,{1 10},{},a);',
   'record=[cell2mat(a) cell2mat(y)];  start=cell2mat(a);',
   'plot3(start(1,1),start(2,1),start(3,1),''kx'',record(1,:),record(2,:),record(3,:),color(rem(i,5)+1))',
   '   drawnow',
   'end',
   'slideData=nnslides(''unlock'',slideData);' };
  slide(7).text={
   'We repeat the simulation for 25 more randomly generated initial conditions.'};

  %========== Slide 8 ==========

  slide(8).code={
   'cla;',
   'plot3(T(1,:),T(2,:),T(3,:),''r*'')',
   'P = [ 1.0  -1.0  -0.5  1.00  1.00  0.0; 0.0   0.0   0.0  0.00  0.00 -0.0;-1.0   1.0   0.5 -1.01 -1.00  0.0];',
   'color = ''rgbmy'';',
   'for i=1:6',
   'a = {P(:,i)};    [y,Pf,Af] = sim(net,{1 10},{},a);',
   'record=[cell2mat(a) cell2mat(y)];  start=cell2mat(a);',
   'plot3(start(1,1),start(2,1),start(3,1),''kx'',record(1,:),record(2,:),record(3,:),color(rem(i,5)+1))',
   '   drawnow',
   'end' };
  slide(8).text={
   ' Now we simulate the Hopfield for the following initial conditions, each a column vector of P:',
   '>> P = [ 1.0  -1.0  -0.5  1.00  1.00  0.0;',
   '             0.0   0.0   0.0  0.00  0.01 -0.0;',
   '            -1.0   1.0   0.5 -1.01 -1.00  0.0]',
   'These points were exactly between the two target stable points.  The result is that they all move into the center of the state space, where an undesired stable point exists.',
   '',
   ''};
end