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

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

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

  slide(1).code={
   'slideData=nnslides(''start'',slideData,''Solving for a Linear Network'');' };
  slide(1).text={
   'NEWLIND  - Solves for a linear layer.',
   'SIM   - Simulates a neural network.',
   '',
   'Using the above functions a linear neuron is designed to respond to specific inputs with target outputs.',
   '',
   ''};

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

  slide(2).code={
   'slideData=nnslides(''blank'',slideData);',
   'P = [1.0 -1.2];',
   'T = [0.5 1.0];' };
  slide(2).text={
   'P defines two 1-element input patterns (column vectors):',
   '>> P = [1.0 -1.2];',
   'T defines the associated 1-element targets (column vectors):',
   '>> T = [0.5 1.0];',
   ''};

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

  slide(3).code={
   'slideData=nnslides(''axes'',slideData);',
   'w_range = -1:0.1:1;',
   'b_range = -1:0.1:1;',
   'ES = errsurf(P,T,w_range,b_range,''purelin'');',
   'plotes(w_range,b_range,ES);',
   'ax=findobj(gcf,''type'',''axes'');',
   '' };
  slide(3).text={
   'ERRSURF calculates errors for a neuron with a range of possible weight and bias values.  PLOTES plots this error surface with a contour plot underneath.',
   '>> w_range = -1:0.1:1; b_range = -1:0.1:1;',
   '>> ES = errsurf(P,T,w_range,b_range,''purelin'');',
   '>> plotes(w_range,b_range,ES);',
   'The best weight and bias values are those that result in the lowest point on the error surface.',
   ''};

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

  slide(4).code={
   '',
   'slideData=nnslides(''blank'',slideData);',
   'net = newlind(P,T);' };
  slide(4).text={
   'The function NEWLIND will design a network that performs with the minimum error:',
   '',
   '>> net = newlind(P,T);',
   ''};

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

  slide(5).code={
   'slideData=nnslides(''blank'',slideData);',
   'format compact;',
   'A=0;E=0;SSE=0;',
   'A = sim(net,P);',
   'E = T - A;',
   'SSE = sumsqr(E);'
   'a=evalc(''A,E,SSE'');'
   'slideData=nnslides(''text'',slideData,a);' };
  slide(5).text={
   'SIM is used to simulate the network for inputs P.',
   '>> A = sim(net,P)',
   'We can then calculate the neurons errors.',
   '>>E = T - A',
   'SUMSQR adds up the squared errors.',
   '>> SSE = sumsqr(E)',
   ''};

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

  slide(6).code={
   'slideData=nnslides(''axes'',slideData);',
   'plotes(w_range,b_range,ES);',
   'plotep(net.IW{1,1},net.b{1},SSE);',
   '' };
  slide(6).text={
   'PLOTES replots the error surface.',
   '>> plotes(w_range,b_range,ES);',
   'PLOTEP plots the "position" of the network using the weight and bias values returned by SOLVELIN.',
   '>> plotep(net.IW{1,1},net.b{1},SSE);',
   'As can be seen from the plot, SOLVELIN found the minimum error solution.',
   '',
   ''};

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

  slide(7).code={
   'p = -1.2;',
   'a=0;',
   'a = sim(net,p);',
   'a=evalc(''a'');',
   'slideData=nnslides(''text'',slideData,a);' };
  slide(7).text={
   'We can now test the associator with one of the original inputs, -1.2, and see if it returns the target, 1.0.',
   '>> p = -1.2;',
   '>> a = sim(net,p)',
   '(see above for answer)',
   ''};
end