Home > atmlab > examples > example_heading.m

example_heading

PURPOSE ^

FUNCNAME A template for function headers.

SYNOPSIS ^

function [a1,a2] = example_heading(b,c,d,e)

DESCRIPTION ^

 FUNCNAME   A template for function headers.

    The line above gives a very short summary of the function. Write the 
    line carefully as it is used by Matlab for special purposes. For example, 
    the default for the *lookfor* function is to only look at the first 
    comment line.

    Below the first line follows a description of the function, with 
    paragraphs separated with empty rows.

    The format described here differs in two aspects from the format used by
    MathWorks. First, the output and input arguments are described below by a
    parameter list (instead of a free text), pretty much as normally done in
    e.g. C programming. Second, reference to variables and functions are here
    indicated as * * (instead of using capital letters).  For example, "input
    argument *b* must be a string, which as passed on to the function
    *some_fun*". An exception is the first line of the header where the Matlab
    style is used. Another difference to the Matlab style is that the function
    declaration is put after the header part (instead of at the top).

    The function is first described by giving the format. Optional input
    arguments are given inside square brackets ([]). The output and input
    arguments are then listed following the example below. 

    It is good practice to give optional input arguments clear default 
    values, which should be given in the function header. It is normally
    better to start the function by setting not given input to the default
    values, than putting more complicated if statements in the code. 
    This strategy should also be less likely to give unexpected side-effects
    if more input arguments are added. Example on how to set default 
    values are given inside the function below.

    Notice that the history log is not part of the header, and there should
    be an empty line before the log.

 FORMAT   [a1,a2] = example_heading(b,c[,d,e])
        
 OUT   a1   A descrition of the variable.
       a2   A descrition of the variable.
 IN    b    A descrition of the variable. The description can run over 
            several lines. 
       c    A descrition of the variable.
 OPT   d    A descrition of the variable. Default is false.
       e    A descrition of the variable. Default is 1.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

example_heading.m

SOURCE CODE ^

0001 % FUNCNAME   A template for function headers.
0002 %
0003 %    The line above gives a very short summary of the function. Write the
0004 %    line carefully as it is used by Matlab for special purposes. For example,
0005 %    the default for the *lookfor* function is to only look at the first
0006 %    comment line.
0007 %
0008 %    Below the first line follows a description of the function, with
0009 %    paragraphs separated with empty rows.
0010 %
0011 %    The format described here differs in two aspects from the format used by
0012 %    MathWorks. First, the output and input arguments are described below by a
0013 %    parameter list (instead of a free text), pretty much as normally done in
0014 %    e.g. C programming. Second, reference to variables and functions are here
0015 %    indicated as * * (instead of using capital letters).  For example, "input
0016 %    argument *b* must be a string, which as passed on to the function
0017 %    *some_fun*". An exception is the first line of the header where the Matlab
0018 %    style is used. Another difference to the Matlab style is that the function
0019 %    declaration is put after the header part (instead of at the top).
0020 %
0021 %    The function is first described by giving the format. Optional input
0022 %    arguments are given inside square brackets ([]). The output and input
0023 %    arguments are then listed following the example below.
0024 %
0025 %    It is good practice to give optional input arguments clear default
0026 %    values, which should be given in the function header. It is normally
0027 %    better to start the function by setting not given input to the default
0028 %    values, than putting more complicated if statements in the code.
0029 %    This strategy should also be less likely to give unexpected side-effects
0030 %    if more input arguments are added. Example on how to set default
0031 %    values are given inside the function below.
0032 %
0033 %    Notice that the history log is not part of the header, and there should
0034 %    be an empty line before the log.
0035 %
0036 % FORMAT   [a1,a2] = example_heading(b,c[,d,e])
0037 %
0038 % OUT   a1   A descrition of the variable.
0039 %       a2   A descrition of the variable.
0040 % IN    b    A descrition of the variable. The description can run over
0041 %            several lines.
0042 %       c    A descrition of the variable.
0043 % OPT   d    A descrition of the variable. Default is false.
0044 %       e    A descrition of the variable. Default is 1.
0045 
0046 % 2002-12-07   Created by Patrick Eriksson
0047 % 2002-12-09   A big improvement by PE.
0048 
0049 
0050 function [a1,a2] = example_heading(b,c,d,e)
0051 %
0052 [b,c,d,e] = funcinput( varargin, 2, {false,[]} )
0053 
0054 %- Input checks                                                       %&%
0055 %                                                                     %&%
0056 % The comment string %&% marks lines that can be removed for          %&%
0057 % 'operational applications'. See README.                             %&%
0058 %                                                                     %&%
0059 rqre_datatype( b, {@ischar} );                                        %&%
0060 rqre_datatype( c, {@ischar,@istensor2} );                             %&%
0061 rqre_datatype( d, {@isboolean} );                                     %&%
0062 rqre_datatype( e, {@istensor0} );                                     %&%
0063 rqre_in_range( e, 1, 3 );                                             %&%
0064 
0065 %- ...
0066 %
0067 a1 = d;
0068 a2 = e;

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005