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

%   Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved
%   $Revision: 1.5 $

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

  slide(1).code={
   'str = {''   ''',
   ''' ''',
   ''' ''',
   ''' ''',
   '''                             MATLAB Programming''',
   ''' ''',
   '''                                  A Quick Start''};'
   'lstxt(str);' };
  slide(1).text=['MATLAB is a powerful forth generation programming',...
    'language as well as an interactive computational environment.',...
    'Using a text editor to write the MATLAB language,  you can create',...
    'custom files that extend MATLAB to include specialized functions',...
    'and scripts for your needs.',...
    ' ',...
   'This example, will walk you through creating an M-file and',...
   'showing you how easy MATLAB is to learn.'];

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

  slide(2).code={
   'str={''x = 5;''',
   '''y = 10;''',
   '''a = 2*x+y/3;''',
   '''z = a^2 - x;''',
   '''c = sqrt(x+y+a+z)''};',
   'lstxt(str);' };
  slide(2).text=['Files that contain code in the MATLAB language are',...
    'called M-files. M-files can be functions that accept arguments',...
    'and produce output, or they can be simple scripts that execute',...
    'a series of MATLAB statements.  In both cases, the name of the',...
    'file has to have a .m extension, such as foo.m',...
    ' ',...
    'Here is the content of an example MATLAB script file.',...
    ' ',...
    'This is the same as if you were to type in these statements on',...
    'the MATLAB command line.  MATLAB scripts are helpful in situations',...
    'were you don''t want to retype a set of commands or to generate',...
    'a set of variables.'];

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

  slide(3).code={
   'str ={''function out = foo(x)''',
   ''' ''',
   '''y = sin(2*pi/x) + cos(pi*x);''',
   ''' ''',
   '''out = y;''};',
   ' lstxt(str);',
   '',
   '',
   '' };
  slide(3).text=['Here is an example MATLAB function file. You know',...
    'that it is a function file since the first line of the code starts',...
    'with the word function.',...
    ' ',...
    'This example, takes in one input and displays  its output based on',....
    'the input.'];

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

  slide(4).code={
   'str ={''>> var = foo(20)''',
   ''' ''',
   '''var =''',
   ''' ''',
   '''       1.3090''',
   ''' ''',
   '''>>''};',
   'lstxt(str);',
   '' };
  slide(4).text={
   'This is how we would call the function we just wrote.'};

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

  slide(5).code={
   'str = {''function y = average(x)''',
   '''% AVERAGE Mean of Vector element''',
   '''%AVERAGE(X), where X is a vector, is the mean of vector elements.''',
   '''% Non-vector inputs results in an error.''',
   ''' ''',
   '''[m,n] = size(x)''',
   '''if (~(m == 1) | (n==1)) | (m == 1 & n == 1))''',
   '''       error(''''Input must be a vector.'''');''',
   '''end''',
   '''y = sum(x)/length(x);''};',
   'lstxt(str);',
   '' };
  slide(5).text=['You can create a custom M-file that also',...
   'contains help for other usersa. The second comment line in',...
   'a function file is the start of help for the function and',...
   'will be display if the user typed:',...
   ' ',...
   '>>help foo',...
   '',...
   ''];

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

  slide(6).code={
   'str ={''>> help average''',
   '''  ''',
   '''  AVERAGE Mean of Vector elements.''',
   '''  AVERAGE(X), where X is a vector , is the mean of vector elements.''',
   '''  Non - vector inputs results in an error''',
   '''  ''',
   '''>>''};',
   'lstxt(str);',
   '' };
  slide(6).text={
   'Here is the result if we typed:',
   '',
   '>>help avereage'};

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

  slide(7).code={
   'str = {'' function myfun(input1, input2)''',
   '''%Type the help for the function here... ''',
   ''' ''',
   '''%Call the plot function here ''',
   ''' ''',
   ''' %Hint: To plot a straight line between 1 and 10, you do this:''',
   ''' >>plot(1:10);''',
   ''' ''',
   '''%You might also want to do some checking to make sure that''',
   '''%the inputs are numerics''};',
   'lstxt(str);' };
  slide(7).text={'Now it''s your turn.',
   ' ',
   'Use an editor and create a MATLAB function called myfun.m that',
   'takes in two inputs and plots a straight line between the two points.'
   ' '
   'You can use the above template as a guide'};
  
end
