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

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

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

  slide(1).code={
   'slideData=nnslides(''start'',slideData,''Adaptive Linear Layer'');' };
  slide(1).text={
   'NEWLIN - Creates a linear layer.',
   'TRAIN  - Trains a neural network.',
   'ADAPT  - Allows a neural network to adapt.',
   '',
   'Using the above functions a linear neuron is allowed to adapt so that given one signal, it can predict a second signal.',
   ''};

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

  slide(2).code={
   'slideData=nnslides(''blank'',slideData);',
   'time = 1:0.01:2.5;',
   'X = sin(sin(time).*time*10);',
   'P = con2seq(X);',
   'T = con2seq(2*[0 X(1:(end-1))] + X);',
   '',
   '' };
  slide(2).text={
   'TIME defines the time steps of this simulation.',
   '>> time = 1:0.01:2.5;',
   'P defines a signal over these time steps:',
   '>> X = sin(sin(time).*time*10);',
   '>> P = con2seq(X);',
   'T is a signal derived from P by shifting it to the left, multiplying it by 2 and adding it to itself:',
   '>> T = con2seq(2*[0 X(1:(end-1))] + X);',
   '',
   ''};

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

  slide(3).code={
   'slideData=nnslides(''axes'',slideData);',
   'slideData=nnslides(''wipeaxes'',slideData'');',
   'plot(time,cat(2,P{:}),time,cat(2,T{:}),''--'')',
   'title(''Input and Target Signals'')',
   'xlabel(''Time'')',
   'ylabel(''Input \_\_\_  Target \_ \_'')',
   '' };
  slide(3).text={
   'Here is how the two signals are plotted:',
   '>> plot(time,cat(2,P{:}),time,cat(2,T{:}),''--'')',
   '>> title(''Input and Target Signals'')',
   '>> xlabel(''Time'')',
   '>> ylabel(''Input \_\_\_  Target \_ \_'')',
   ''};

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

  slide(4).code={
   'slideData=nnslides(''blank'',slideData);',
   'net = newlin([-3 3],1,[0 1],0.1);' };
  slide(4).text={
   'The linear network must have tapped delay in order to learn the time-shifted correlation between P and T:  NEWLIN creates a linear layer.',
   '>> net = newlin([-3 3],1,[0 1],0.1);',
   '[-3 3] is the expected input range.  The second argument is the number of neurons in the layer.  [0 1] specifies one input with no delay and one input with a delay of one.  The last argument is the learning rate.'};

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

  slide(5).code={
   'slideData=nnslides(''axes'',slideData);',
   'plot(time,cat(2,T{:}),''r'');',
   'hold on;',
   'plot([1 2.5],[0 0],''k'');',
   'title(''Output and Target and Error Signals'');',
   'xlabel(''Time''); ylabel(''Output-blue  Target-red  Error-green'');',
   'YN=0; EN=0; TimeN=time(1);',
   'for i=2:length(P);',
   '   TimeO=TimeN;',
   '   TimeN=time(i);',
   '   YO=YN;',
   '   EO=EN;',
   '   [net,Y,E,Pf]=adapt(net,P{i},T{i});',
   '   YN=Y(1);',
   '   EN=E(1);',
   '   plot([TimeO TimeN],[YO YN],''b'',[TimeO TimeN],[EO EN],''g'');',
   '   drawnow;',
   'end;',
   'hold off;' };
  slide(5).text={
   'ADAPT simulates adaptive networks.  It takes a nework, a signal, and a target signal, and filters the signal adaptively.',
   '>> [net,Y,E,Pf]=adapt(net,P,T);',
   'Plot the the output Y in blue, the target T in red and the error E in green:',
   '>> plot(time,cat(2,Y{:}),''b'',time,cat(2,T{:}),''r'',time,cat(2,E{:}),''g'',[1 2.5],[0 0],''k''))',
   'By t=2 the network has learned the relationship between the input and the target  and the error drops to near zero.'};
end