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

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

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

  slide(1).code={
   'cla reset',
   'axis(''off'')',
   'axis([-10 10 0 10])',
   't = text(0,7,''DEMOGRN1:'');',
   'set(t,''horiz'',''center'')',
   'set(t,''fontweight'',''bold'',''fontsize'',16)',
   't = text(0,5,''Generalized Regression Neural Network'');',
   'set(t,''horiz'',''center'',''color'',[1 0 0.5])',
   'set(t,''fontweight'',''bold'',''fontsize'',16)',
   't = text(0,3.5,''Function Approximation'');',
   '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 function',
   ' approximation with a generalized regression neural network.',
   '',
   ' This demonstration uses NNT functions NEWGRNN and SIM.'};

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

  slide(2).code={
   'cla reset',
   'axis(''on'')',
   'P = [1 2 3 4 5 6 7 8];',
   'T = [0 1 2 3 2 1 2 1];',
   'plot(P,T,''.'',''markersize'',30)',
   'axis([0 9 -1 4])',
   'title(''Function to approximate.'')',
   'xlabel(''P'')',
   'ylabel(''T'')' };
  slide(2).text={
   ' Here are eight data points of a function we would like to fit.',
   ' The functions inputs P should result in target outputs T.',
   ' >> P = [1 2 3 4 5 6 7 8];',
   ' >> T = [0 1 2 3 2 1 2 1];',
   ' >> plot(P,T,''.'',''markersize'',20)',
   ' >> axis([0 9 -1 4])'};

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

  slide(3).code={
   'cla reset',
   'spread = 0.7;',
   'net = newgrnn(P,T,spread);',
   'A = sim(net,P);',
   'plot(P,T,''.'',''markersize'',30)',
   'axis([0 9 -1 4])',
   'hold on',
   'plot(P,A,''.'',''markersize'',30,''color'',[1 0 0])',
   'title(''Create and test a network.'')',
   'xlabel(''P'')',
   'ylabel(''T and A'')' };
  slide(3).text={
   'We use NEWGRNN to create a generalized regression network.  We use a SPREAD slightly lower than 1, the distance between input values, in order, to get a function that fits individual data points fairly closely. A smaller spread would fit data better but be less smooth.',
   ' >> spread = 0.7; net = newgrnn(P,T,spread);',
   ' >> A = sim(net,P);',
   ' >> plot(P,T,''.'',''markersize'',30)',
   ' >> hold on, plot(P,A,''.'',''markersize'',30,''color'',[1 0 0])'};

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

  slide(4).code={
   'cla reset',
   'p = 3.5;',
   'a = sim(net,p);',
   'plot(P,T,''.'',''markersize'',30)',
   'axis([0 9 -1 4])',
   'hold on',
   'plot(p,a,''.'',''markersize'',30,''color'',[1 0 0])',
   'title(''New input value.'')',
   'xlabel(''P and p'')',
   'ylabel(''T and a'')' };
  slide(4).text={
   'We can use the network to approximate the function at a new input value.',
   '>> p = 3.5;',
   '>> a = sim(net,p);',
   '',
   '>> plot(P,T,''.'',''markersize'',30)',
   '>> hold on, plot(p,a,''.'',''markersize'',30,''color'',[1 0 0])'};

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

  slide(5).code={
   'cla reset',
   'P2 = 0:.1:9;',
   'A2 = sim(net,P2);',
   'plot(P2,A2,''linewidth'',4,''color'',[1 0 0])',
   'hold on',
   'plot(P,T,''.'',''markersize'',30)',
   'axis([0 9 -1 4])',
   'title(''Function to approximate.'')',
   'xlabel(''P and P2'')',
   'ylabel(''T and A2'')' };
  slide(5).text={
   'Here the network''s response is simulated for many values, allowing us to see the function it represents.',
   '>> P2 = 0:.1:9;',
   '>> A2 = sim(net,P2);',
   '>> plot(P2,A2,''linewidth'',4,''color'',[1 0 0])',
   '>> hold on, plot(P,T,''.'',''markersize'',30)'};
end