Standard MATLAB Help
Authored by the MATLAB and Simulink user community on the MATLAB Wiki.
The help for the functions in MATLAB is listed in the first block of comments after the function declaration. For example to look at the source for MEAN.M.
| Table of contents |
An example
See the Multiplication Toolbox for more information about this file.
%TIMESRAND Multiply the input by a random number. % TIMESRAND(X) returns the value of the input X multiplied by a random % number. If no second argument is applied, the RAND function is used % to create a random multiplier. % TIMESRAND(X, 'uniform') uses RAND to generate the multiplier. % TIMESRAND(X, 'normal') uses RANDN to generate the multiplier. % % Example: % x = [0 1 2] % y = timesrand(x) % % See also TIMES2, TIMES3, TIMES37. % Copyright 2006 F.X. Selector
Notice the spacing. The comment character (%) is always in the first column. On line one, the file name begins in column 2. On all subsequent lines the text begins no sooner than column 5.
Let's look at each part of the help text.
Description
%TIMESRAND Multiply the input by a random number.
All capital letters for the name of the function, and a terse one line description of what the function does. Ends with a period. This is sometimes referred to as the H-1 line.
Longer description
% TIMESRAND(X) returns the value of the input X multiplied by a random % number. If no second argument is applied, the RAND function is used % to create a random multiplier.
Notice that the name of the function is always in all capital letters.
Calling syntaxes
% TIMESRAND(X, 'uniform') uses RAND to generate the multiplier. % TIMESRAND(X, 'normal') uses RANDN to generate the multiplier.
List the various ways to call the function.
- Support a variety of input syntaxes if appropriate
- Support array inputs so that users do not have to call the function repeatedly with scalar input
- Provide appropriate input and output syntax error checking.
Examples
% Example: % X = [0 1 2] % Y = timesrand(X)
The example allows people to run the function in its most basic way. There can be more than one example. The word "Example" appears on a line by itself. Don't mix prose and code; you must be able to copy and evaluate the code exactly as it appears.
See also
% See also TIMES2, TIMES3, TIMES37.
Related functions are listed here in all capital letters.
Optional contact information
% Copyright 2006 F.X. Selector
The optional contact information is a separate comment block so that it does not appear when people type "help timesrand". Copyright (if desired) and author names go here.