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

% Copyright 1992-2000 The MathWorks, Inc.
% $Revision: 1.6 $  $Date: 2000/08/15 16:56:10 $

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

  slide(1).code={
   'cla reset',
   'axis(''off'')',
   'axis([-10 10 0 10])',
   't = text(0,7,''DEMOPNN1:'');',
   'set(t,''horiz'',''center'')',
   'set(t,''fontweight'',''bold'',''fontsize'',16)',
   't = text(0,5,''Probabilistic Neural Network'');',
   'set(t,''horiz'',''center'',''color'',[1 0 0.5])',
   'set(t,''fontweight'',''bold'',''fontsize'',16)',
   't = text(0,3.5,''Classification'');',
   'set(t,''horiz'',''center'',''color'',[1 0 0.5])',
   'set(t,''fontweight'',''bold'',''fontsize'',16)' };
  slide(1).text={
   ' Press the "Start" button to see a demonstration of classification',
   ' with a probabilistic neural network.',
   '',
   ' This demonstration uses NNT functions NEWPNN and SIM.'};

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

  slide(2).code={
   'cla reset',
   'axis(''on'')',
   '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(''Three vectors and their classes.'')',
   'xlabel(''P(1,:)'')',
   'ylabel(''P(2,:)'')' };
  slide(2).text={
   ' Here are three two-element input vectors P and their associated',
   ' classes Tc.  We would like to create a probabilistic neural network',
   ' that classifes these vectors properly.',
   '>> 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])'};

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

  slide(3).code={
   'cla reset',
   'T = ind2vec(Tc);',
   'spread = 1;',
   'net = newpnn(P,T,spread);',
   '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(''Three vectors and their classes.'')',
   'xlabel(''P(1,:)'')',
   'ylabel(''P(2,:)'')' };
  slide(3).text={
   ' First we convert the target class indices Tc to vectors T.  Then we design a probabilistic neural network with NEWPNN.  We use a SPREAD value of 1 because that is a typical distance between the input vectors.',
   '>> T = ind2vec(Tc);',
   '>> spread = 1;',
   '>> net = newpnn(P,T,spread);'};

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

  slide(4).code={
   'cla reset',
   'A = sim(net,P);',
   'Ac = vec2ind(A);',
   'plot(P(1,:),P(2,:),''.'',''markersize'',30)',
   'axis([0 3 0 3])',
   'title(''Testing the network.'')',
   'xlabel(''P(1,:)'')',
   'ylabel(''P(2,:)'')',
   'for i=1:3,pause(1),text(P(1,i)+0.1,P(2,i),sprintf(''class %g'',Ac(i))),end' };
  slide(4).text={
   'Now we test the network on the design input vectors.  We do this by simulating the network and converting its vector outputs to indices.',
   '>> A = sim(net,P);',
   '>> Ac = vec2ind(A);',
   '>> plot(P(1,:),P(2,:),''.'',''markersize'',30)',
   '>> for i=1:3, text(P(1,i)+0.1,P(2,i),sprintf(''class %g'',Ac(i))), end'};

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

  slide(5).code={
   'cla reset',
   'p = [2; 1.5];',
   'a = sim(net,p);',
   'ac = vec2ind(a);',
   'hold on',
   'plot(P(1,:),P(2,:),''.'',''markersize'',30)',
   'for i=1:3,text(P(1,i)+0.1,P(2,i),sprintf(''class %g'',Ac(i))),end',
   'plot(p(1),p(2),''.'',''markersize'',30,''color'',[1 0 0])',
   'hold off',
   'axis([0 3 0 3])',
   'title(''Classifying a new vector.'')',
   'xlabel(''P(1,:) and p(1)'')',
   'ylabel(''P(2,:) and p(2)'')',
   'pause(1)',
   'text(p(1)+0.1,p(2),sprintf(''class %g'',ac))' };
  slide(5).text={
   ' Let''s classify a new vector with our network.',
   '>> p = [2; 1.5];',
   '>> a = sim(net,p);',
   '>> ac = vec2ind(a);',
   '>> plot(p(1),p(2),''.'',''markersize'',30)',
   '>> text(p(1)+0.1,p(2),sprintf(''class %g'',ac))'};

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

  slide(6).code={
   'cla reset, drawnow',
   'p1 = 0:.05:3;',
   'p2 = p1;',
   '[P1,P2]=meshgrid(p1,p2);',
   'pp = [P1(:) P2(:)]'';',
   'aa = sim(net,pp);',
   'aa = full(aa);',
   'm = mesh(P1,P2,reshape(aa(1,:),length(p1),length(p2)));',
   'set(m,''facecolor'',[0 0.5 1],''linestyle'',''none'');',
   'hold on',
   'm = mesh(P1,P2,reshape(aa(2,:),length(p1),length(p2)));',
   'set(m,''facecolor'',[0 1.0 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'',30,''color'',[1 0 0])',
   'hold off',
   'view(2)',
   'title(''The three classes.'')',
   'xlabel(''P(1,:) and p(1)'')',
   'ylabel(''P(2,:) and p(2)'')' };
  slide(6).text={
   ' The diagram above shows how the probabilistic neural network',
   ' divides the input space into the three classes.'};
end