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

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 5.16 $

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

  slide(1).code={
   'h=findobj(gcf, ''tag'', ''uic'');',
   'if ~isempty(h), delete(h), end;',
   'load logo',
   '  n = length(L(:,1));',
   '  surf(L,R), colormap(M)',
   '  axis off, axis([1 n 1 n -.2 .35]), view(-37.5,60)',
   '  title(''"Life is too short to spend writing DO loops..."'');' };
  slide(1).text={
   ' Press the "Start" button to see a brief introduction',
   ' to the power of the MATLAB programming language.',
   ' All of the demos (including this one) are written in',
   ' MATLAB language M-files.',
   ' >> load logo',
   ' >> surf(L,R), colormap(M)',
   ' >> n = size(L,1);',
   ' >> axis off, axis([1 n 1 n -.2 .35]), view(-37.5,60)',
   ' >> title(''"Life is too short to spend writing DO loops..."'');'};

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

  slide(2).code={
   'ord = get(gcf,''defaultaxescolororder'');',
   'set(gcf,''defaultaxescolororder'',hsv(20))',
   'c = peaks; contour(c,20);',
   'surface(ones(size(c)),c);',
   'colormap(hsv(20)); shading flat',
   'view(3)',
   'title(''"An ounce of MATLAB is worth a pound of C or FORTRAN..."'');',
   'set(gcf,''defaultaxescolororder'',ord);' };
  slide(2).text={
   ' MATLAB is a powerful programming language.',
   ' It is such a compact and highly efficient language that,',
   ' line-for-line, a MATLAB program may contain some',
   ' of the most potent code you ever write.',
   ' >> c = peaks; contour(c,20);',
   ' >> surface(ones(size(c)),c);',
   ' >> colormap(hsv(20)); shading flat',
   ' >> view(3)'};

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

  slide(3).code={
   'imagesc(flipud(peaks));',
   'colormap(hsv);',
   'title(''"Think of MATLAB as a power tool for your brain..."'')' };
  slide(3).text={
   ' MATLAB programs, or M-files, are ascii files denoted by',
   ' the filename suffix ".m" and come in two basic flavors:',
   ' SCRIPTS and FUNCTIONS.',
   '',
   ' >> imagesc(flipud(peaks));',
   ' >> colormap(hsv);',
   ' >> title(''"Think of MATLAB as a power tool for your brain..."'')'};

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

  slide(4).code={
   'cla reset',
   'set(gca,''Box'',''on'',''XTick'',[],''YTick'',[],''Visible'',''on'');',
   'text(.05,.9,''% fibscript.m'');',
   'text(.05,.8,''% A script to calculate Fibonacci numbers'');',
   'text(.05,.7,''% first described by Leonardo of Pisa.'');',
   'text(.05,.6,''f = [1 1]; n = 1;'');',
   'text(.05,.5,''while f(n) + f(n + 1) < 80'');',
   'text(.05,.4,''    f(n + 2) = f(n) + f(n + 1)'');',
   'text(.05,.3,''    n = n + 1;'');',
   'text(.05,.2,''end'');',
   'text(.05,.1,''f'');' };
  slide(4).text={
   ' When the name of a SCRIPT M-file is typed at the',
   ' command line, MATLAB simply executes the commands',
   ' found in the file.',
   '',
   ' This can be used to automate long sequences of',
   ' commands.',
   ' >> set(gca,''Box'',''on'',''XTick'',[ ],''YTick'',[ ],''Visible'',''on'');',
   ' >> text(.05,.9,''% fibscript.m'');',
   ' >> text(.05,.8,''% A script to calculate Fibonacci numbers'');'};

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

  slide(5).code={
   'cla reset',
   'set(gca,''Box'',''on'',''XTick'',[],''YTick'',[],''Visible'',''on'');',
   'text(.05,.9,''function f = fibfun(n)'');',
   'text(.05,.8,''% FIBFUN For calculating Fibonacci numbers.'');',
   'text(.05,.7,''% Incidentally, the name Fibonacci comes from'');',
   'text(.05,.6,''% Filius Bonassi, or "son of Bonassus".'');',
   'text(.05,.5,''if n > 2'');',
   'text(.05,.4,''    f = fibfun(n - 1) + fibfun(n - 2);'');',
   'text(.05,.3,''else'');',
   'text(.05,.2,''    f = 1;'');',
   'text(.05,.1,''end'');' };
  slide(5).text={
   ' A FUNCTION M-file is like a SCRIPT, except that it allows',
   ' argument passing and local variables.',
   '',
   ' Many of the MATLAB commands available at the command',
   ' line are actually FUNCTION M-files that are open for',
   ' your inspection.'};

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

  slide(6).code={
   'cla reset',
   'set(gca,''Box'',''on'',''XTick'',[],''YTick'',[],''Visible'',''on'');',
   'text(.05,.9,''>> fibfun(10)'');',
   'text(.05,.8,''ans ='');',
   'text(.05,.7,''    55'');',
   'text(.05,.5,''>> help fibfun'');',
   'text(.05,.4,''FIBFUN For calculating Fibonacci numbers.'');',
   'text(.05,.3,''Incidentally, the name Fibonacci comes from'');',
   'text(.05,.2,''Filius Bonassi, or "son of Bonassus".'');' };
  slide(6).text={
   ' For example, once the Fibonacci function has been defined,',
   ' we can use it at the command line, as shown above.',
   '',
   ' In this way, MATLAB is extensible.  The sky''s the limit.',
   '',
   ' (For example, all of demos are written in MATLAB M-files.)'};

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

  slide(7).code={
   'cla reset',
   'set(gca,''Box'',''on'',''XTick'',[],''YTick'',[],''Visible'',''on'');',
   'text(.1,.9,''Think VECTORIZED, i.e. use'');',
   'text(.2,.75,''y = sum(x);'');',
   'text(.1,.6,''instead of'');',
   'text(.2,.45,''y = 0;'');',
   'text(.2,.35,''for i = 1:length(x)'');',
   'text(.2,.25,''    y = y + x(i);'');',
   'text(.2,.15,''end'');' };
  slide(7).text={
   ' In M-files, the familiar IF, WHILE, and FOR statements of',
   ' other programming languages can be used for control flow.',
   '',
   ' Nevertheless, some of the most ingenious and efficient',
   ' M-files use MATLAB''s built-in vector and matrix',
   ' operations instead of explicit loops.'};

  %========== Slide 8 ==========

  slide(8).code={
   'cla reset',
   'set(gca,''Box'',''on'',''XTick'',[],''YTick'',[],''Visible'',''on'');',
   'text(.05,.9,''dbstop''); text(.3,.9,''Set breakpoint.'');',
   'text(.05,.8,''dbclear''); text(.3,.8,''Remove breakpoint.'');',
   'text(.05,.7,''dbcont''); text(.3,.7,''Resume execution.'');',
   'text(.05,.6,''dbdown''); text(.3,.6,''Change local workspace context.'');',
   'text(.05,.5,''dbstack''); text(.3,.5,''List who called whom.'');',
   'text(.05,.4,''dbstatus''); text(.3,.4,''List all breakpoints.'');',
   'text(.05,.3,''dbstep''); text(.3,.3,''Execute one or more lines.'');',
   'text(.05,.2,''dbtype''); text(.3,.2,''List M-file with line numbers.'');',
   'text(.05,.1,''dbup''); text(.3,.1,''Change local workspace context.'');' };
  slide(8).text={
   ' And, in the event that you should have a hard-to-find',
   ' bug in an M-file you create, MATLAB is equipped with a',
   ' powerful debugger to root out any problems.',
   '',
   ' The debugger provides a variety of familiar and useful',
   ' functions, like set breakpoint, resume execution, etc...'};

  %========== Slide 9 ==========

  slide(9).code={
   'h=findobj(gcf, ''tag'', ''uic'');',
   'if ~isempty(h), delete(h), end;',
   'cla reset',
   'image, colormap(gray(32))',
   'axis ij, axis equal, axis off',
   't = get(gca,''Title'');',
   'set(t,''String'',''"Read my lips.  MATLAB is great..."'');' };
  slide(9).text={
   ' To summarize, anything that you can type at the command',
   ' line can be placed into an M-file.  This has several',
   ' important implications.',
   '',
   ' First, you have the incredibly powerful vector and matrix',
   ' notation of MATLAB to make your code concise.',
   '',
   '>> image, colormap(gray(32))',
   '>> axis ij, axis equal,  axis off'};


  %========== Slide 10 ==========

  slide(10).code={
   'cla reset',
   'set(gca,''Box'',''on'',''XTick'',[],''YTick'',[],''Visible'',''on'');',
   'drawnow',
   'h = [];',
   'i = 1;',
   'pos = get(gca,''Position'');',
   'x = .5; x2 = pos(3) * x + pos(1);',
   'y = .9 - (i-1) * .15; y2 = pos(4) * y + pos(2);',
   'text(.2,y,''pushbuttons'')',
   'h(i) = uicontrol(''Style'',''pushbutton'',''Units'',''normalized'', ''String'',''Push Me'',''Position'',[x2 y2-.03 .15 .05], ''Tag'', ''uic'');',
   'i = i + 1;',
   'y = .9 - (i-1) * .15; y2 = pos(4) * y + pos(2);',
   'text(.2,y,''radiobuttons'')',
   'h(i) = uicontrol(''Style'',''radiobutton'',''Units'',''normalized'', ''String'',''Click Me'',''Position'',[x2 y2-.03 .15 .05], ''Tag'', ''uic'');',
   'i = i + 1;',
   'y = .9 - (i-1) * .15; y2 = pos(4) * y + pos(2);',
   'text(.2,y,''checkboxes'')',
   'h(i) = uicontrol(''Style'',''checkbox'',''Units'',''normalized'',  ''String'',''Click Me'',''Position'',[x2 y2-.03 .15 .05], ''Tag'', ''uic'');',
   'i = i + 1;',
   'y = .9 - (i-1) * .15; y2 = pos(4) * y + pos(2);',
   'text(.2,y,''edit boxes'')',
   'h(i) = uicontrol(''Style'',''edit'',''Units'',''normalized'', ''String'',''    Edit Me'',''Position'',[x2 y2-.03 .15 .05], ''Tag'', ''uic'');',
   'i = i + 1;',
   'y = .9 - (i-1) * .15; y2 = pos(4) * y + pos(2);',
   'text(.2,y,''text'')',
   'h(i) = uicontrol(''Style'',''text'',''Units'',''normalized'',   ''String'',''Static Text'',''Position'',[x2 y2-.03 .15 .05], ''Tag'', ''uic'');',
   'i = i + 1;',
   'y = .9 - (i-1) * .15; y2 = pos(4) * y + pos(2);',
   'text(.2,y,''sliders'')',
   'h(i) = uicontrol(''Style'',''slider'',''Units'',''normalized'', ''Value'',.5,''Position'',[x2 y2-.03 .15 .05], ''Tag'', ''uic'');' };
  slide(10).text={
   ' Second, MATLAB invisibly handles all memory allocation,',
   ' and supports file I/O and string manipulation.',
   '',
   ' Finally, MATLAB contains an extensive collection of',
   ' graphical interface tools (shown above) that you can use to',
   ' build beautiful and useful user interfaces.',
   '',
   ' >> text(.2,y,''pushbuttons'')',
   ' >> h(i) = uicontrol(''Style'',''pushbutton'',''Units'',''normalized'', ...',
   '         ''String'',''Push Me'',''Position'',[x2 y2-.03 .15 .05]);'};

  %========== Slide 11 ==========

  slide(11).code={
   '% delete(h),',
   'if exist(''h''), for i=1:6, set(h(i), ''visible'', ''off''); end; end;',
   'cla',
   'cla reset',
   'cplxroot(3,15);',
   'colormap(hsv);',
   'title(''f(z) = z^{(1/3)}'');' };
  slide(11).text={
   ' And, of course, you can invoke any of the functions that',
   ' make MATLAB the premier program for numerical linear',
   ' algebra, matrix manipulation and data visualization.',
   '',
   ' For example, we can plot the Riemann surface for z^(1/3).',
   ' >> cplxroot(3,15);',
   ' >> colormap(hsv);',
   ' >> title(''f(z) = z^{(1/3)}'');'};

  %========== Slide 12 ==========

  slide(12).code={
   'cla',
   'load logo',
   'n = length(L(:,1));',
   'surf(L,R), colormap(M)',
   'n = size(L,1);',
   'axis off, axis([1 n 1 n -.2 .35]), view(-37.5,60)',
   'title(''MATLAB.  Picture the Power.'');' };
  slide(12).text={
   ' Study the M-files that are shipped with MATLAB, and you',
   ' will be amazed by some of the ingenuity and power of the',
   ' MATLAB programming language.',
   '',
   ' MATLAB.  Picture the Power.',
   '',
   ' >> load logo',
   ' >> surf(L,R), colormap(M)',
   ' >> n = size(L,1);',
   ' >> axis off, axis([1 n 1 n -.2 .35]), view(-37.5,60)'};
end
