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

% Copyright (c) 1992-1998 by The MathWorks, Inc.
% $Revision: 1.13 $  $Date: 1998/06/25 12:12:12 $

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

  slide(1).code={
   'slideData=nnslides(''start'',slideData,''Self-Organizing Map'');' };
  slide(1).text={
   'NEWSOM   - Creates a self-organizing map.',
   'TRAIN  - Trains a neural network.',
   'SIM   - Simulates a neural network.',
   '',
   'Neurons in a 2-D layer learn to represent different regions of the input space where input vectors occur.  In addition, neighboring neurons learn to respond to similar inputs, thus the layer learns the topology of the presented input space.',
   ''};

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

  slide(2).code={
   'slideData=nnslides(''axes'',slideData);',
   'angles = 0:0.5*pi/99:0.5*pi;',
   'P = [sin(angles); cos(angles)];',
   'plot(P(1,:),P(2,:),''+r'')',
   '' };
  slide(2).text={
   'Here 100 data points are created on the unit circle:',
   '>> angles = 0:0.5*pi/99:0.5*pi;',
   '>> P = [sin(angles); cos(angles)];',
   'Here the data points are plotted.',
   '>> plot(P(1,:),P(2,:),''+r'')',
   'A competitive network will be used to classify these points into natural classes.',
   ''};

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

  slide(3).code={
   'slideData=nnslides(''blank'',slideData);',
   'net=newsom([0 1;0 1],[10]);' };
  slide(3).text={
   'The map will be a 1-dimensional layer of 10 neurons:',
   '>> net=newsom([0 1;0 1],[10]);',
   'The first argument specifies two inputs, each with a range of 0 to 1.  The second determines the network is one dimensional with 10 neurons.',
   ''};

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

  slide(4).code={
   'slideData=nnslides(''lock'',slideData);',
   'slideData=nnslides(''blank'',slideData);',
   'more off;',
   'net.trainParam.epochs=1000;',
   'net=train(net,P);',
   ' slideData=nnslides(''unlock'',slideData);' };
  slide(4).text={
   'Specify the network is to be trained for 1000 epochs:',
   '>> net.trainParam.epochs=1000;',
   'TRAIN trains the network on the input data P:',
   '>> net=train(net,P);',
   'Please wait a few seconds while the network is being trained before moving to the next slide.'};

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

  slide(5).code={
   'slideData=nnslides(''axes'',slideData);',
   'plotsom(net.iw{1,1},net.layers{1}.distances)',
   '' };
  slide(5).text={
   'Now plot the trained network with PLOTSOM:',
   '>> plotsom(net.iw{1,1},net.layers{1}.distances)',
   'The red dots are the neuron''s weight vectors, and the blue lines connect each pair within a distance of 1.'};

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

  slide(6).code={
   'a=0;',
   'a = sim(net,[1;0]);',
   'out=evalc(''a'');',
   'slideData=nnslides(''text'',slideData,out);' };
  slide(6).text={
   'The map can now be used to classify inputs, like [1; 0]:',
   '>> a=sim(net,[1;0])',
   'Either neuron 1 or 10 should have an output of 1, as the above input vector was at one end of the presented input space.  The first pair of numbers indicate the neuron, and the single indicates its output.'};
end