Mercurial > octave-nkf
diff doc/interpreter/func.txi @ 9209:923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
spellchecked all .txi and .texi files.
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Sun, 17 May 2009 12:18:06 -0700 |
parents | fca0dc2fb042 |
children | ea0d83b4470b |
line wrap: on
line diff
--- a/doc/interpreter/func.txi Sun May 17 21:34:54 2009 +0200 +++ b/doc/interpreter/func.txi Sun May 17 12:18:06 2009 -0700 @@ -249,9 +249,11 @@ functions that return multiple values is @example +@group function [@var{ret-list}] = @var{name} (@var{arg-list}) @var{body} endfunction +@end group @end example @noindent @@ -302,10 +304,12 @@ example, calling the function @example +@group function [x, y, z] = f () x = 1; z = 2; endfunction +@end group @end example @noindent @@ -319,11 +323,13 @@ produces: @example +@group a = 1 b = [](0x0) c = 2 +@end group @end example @noindent @@ -346,8 +352,10 @@ of all its input arguments. For example, @example +@group a = smallest (1, 2, 3); b = smallest (1, 2, 3, 4); +@end group @end example @noindent @@ -355,9 +363,11 @@ the @code{smallest} function is @example +@group function val = smallest (arg1, arg2, arg3, arg4, arg5) @var{body} endfunction +@end group @end example @noindent @@ -371,9 +381,11 @@ looks like this @example +@group function val = smallest (varargin) @var{body} endfunction +@end group @end example @noindent @@ -384,9 +396,11 @@ like this @example +@group function val = smallest (varargin) val = min ([varargin@{:@}]); endfunction +@end group @end example @noindent @@ -398,12 +412,14 @@ can be defined like this @example +@group function print_arguments (varargin) for i = 1:length (varargin) printf ("Input argument %d: ", i); disp (varargin@{i@}); endfor endfunction +@end group @end example @noindent @@ -436,11 +452,13 @@ 1, the second to 2, and so on. @example +@group function varargout = one_to_n () for i = 1:nargout varargout@{i@} = i; endfor endfunction +@end group @end example @noindent @@ -519,9 +537,11 @@ value to the argument like this @example +@group function @var{name} (@var{arg1} = @var{val1}, @dots{}) @var{body} endfunction +@end group @end example @noindent @@ -531,9 +551,11 @@ As an example, the following function implements a variant of the classic ``Hello, World'' program. @example +@group function hello (who = "World") printf ("Hello, %s!\n", who); endfunction +@end group @end example @noindent @@ -583,7 +605,7 @@ searches a list of directories (the @dfn{path}) for files ending in @file{.m} that have the same base name as the undefined identifier.@footnote{The @samp{.m} suffix was chosen for compatibility -with @sc{Matlab}.} Once Octave finds a file with a name that matches, +with @sc{matlab}.} Once Octave finds a file with a name that matches, the contents of the file are read. If it defines a @emph{single} function, it is compiled and executed. @xref{Script Files}, for more information about how you can define more than one function in a single @@ -759,7 +781,7 @@ @noindent which aliases the user-defined function @code{spsin} to @code{sin}, but only for real sparse -matrices. Note that the builtin @code{sin} already correctly treats +matrices. Note that the builtin @code{sin} already correctly treats sparse matrices and so this example is only illustrative. @DOCSTRING(dispatch) @@ -1051,9 +1073,11 @@ @code{fsolve}. For example @example +@group f = @@sin; quad (f, 0, pi) @result{} 2 +@end group @end example You may use @code{feval} to call a function using function handle, or @@ -1062,11 +1086,13 @@ @samp{()}. For example @example +@group f = @@sin; feval (f, pi/4) @result{} 0.70711 f (pi/4) @result{} 0.70711 +@end group @end example @DOCSTRING(functions) @@ -1092,9 +1118,11 @@ example, @example +@group f = @@(x) x.^2; quad (f, 0, 10) @result{} 333.33 +@end group @end example @noindent @@ -1102,18 +1130,22 @@ passes it to @code{quad}, @example +@group quad (@@(x) sin (x), 0, pi) @result{} 2 +@end group @end example @noindent wraps another function, and @example +@group a = 1; b = 2; quad (@@(x) betainc (x, a, b), 0, 0.4) @result{} 0.13867 +@end group @end example @noindent