[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 13. Functions and Script Files

Complicated Octave programs can often be simplified by defining functions. Functions can be defined directly on the command line during interactive Octave sessions, or in external files, and can be called just like built-in functions.

13.1 Defining Functions |  |
13.2 Multiple Return Values |  |
13.3 Variable-length Argument Lists |  |
13.4 Variable-length Return Lists |  |
13.5 Returning From a Function |  |
13.6 Function Files |  |
13.7 Script Files |  |
13.8 Dynamically Linked Functions |  |
13.9 Function Handles and Inline |  |
13.10 Organization of Functions Distributed with Octave |  |

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.1 Defining Functions

In its simplest form, the definition of a function named name looks like this:

    function name
      body
    endfunction

A valid function name is like a valid variable name: a sequence of letters, digits and underscores, not starting with a digit. Functions share the same pool of names as variables.

The function body consists of Octave statements. It is the most important part of the definition, because it says what the function should actually do.

For example, here is a function that, when executed, will ring the bell on your terminal (assuming that it is possible to do so):

    function wakeup
      printf ("\a");
    endfunction

The `printf` statement (see section 16. Input and Output) simply tells Octave to print the string `"\a"`. The special character ``\a`' stands for the alert character (ASCII 7). See section 5. Strings.

Once this function is defined, you can ask Octave to evaluate it by typing the name of the function.

Normally, you will want to pass some information to the functions you define. The syntax for passing parameters to a function in Octave is

    function name (arg-list)
      body
    endfunction

where arg-list is a comma-separated list of the function's arguments. When the function is called, the argument names are used to hold the argument values given in the call. The list of arguments may be empty, in which case this form is equivalent to the one shown above.

To print a message along with ringing the bell, you might modify the `beep` to look like this:

    function wakeup (message)
      printf ("\a%s\n", message);
    endfunction

Calling this function using a statement like this

    wakeup ("Rise and shine!");

will cause Octave to ring your terminal's bell and print the message ``Rise and shine!`', followed by a newline character (the ``\n`' in the first argument to the `printf` statement).

In most cases, you will also want to get some information back from the functions you define. Here is the syntax for writing a function that returns a single value:

    function ret-var = name (arg-list)
      body
    endfunction

The symbol ret-var is the name of the variable that will hold the value to be returned by the function. This variable must be defined before the end of the function body in order for the function to return a value.

Variables used in the body of a function are local to the function. Variables named in arg-list and ret-var are also local to the function. See section 9.1 Global Variables, for information about how to access global variables inside a function.

For example, here is a function that computes the average of the elements of a vector:

    function retval = avg (v)
      retval = sum (v) / length (v);
    endfunction

If we had written `avg` like this instead,

    function retval = avg (v)
      if (isvector (v))
        retval = sum (v) / length (v);
      endif
    endfunction

and then called the function with a matrix instead of a vector as the argument, Octave would have printed an error message like this:

    error: `retval' undefined near line 1 column 10
    error: evaluating index expression near line 7, column 1

because the body of the `if` statement was never executed, and `retval` was never defined. To prevent obscure errors like this, it is a good idea to always make sure that the return variables will always have values, and to produce meaningful error messages when problems are encountered. For example, `avg` could have been written like this:

    function retval = avg (v)
      retval = 0;
      if (isvector (v))
        retval = sum (v) / length (v);
      else
        error ("avg: expecting vector argument");
      endif
    endfunction

There is still one additional problem with this function. What if it is called without an argument? Without additional error checking, Octave will probably print an error message that won't really help you track down the source of the error. To allow you to catch errors like this, Octave provides each function with an automatic variable called `nargin`. Each time a function is called, `nargin` is automatically initialized to the number of arguments that have actually been passed to the function. For example, we might rewrite the `avg` function like this:

    function retval = avg (v)
      retval = 0;
      if (nargin != 1)
        usage ("avg (vector)");
      endif
      if (isvector (v))
        retval = sum (v) / length (v);
      else
        error ("avg: expecting vector argument");
      endif
    endfunction

Although Octave does not automatically report an error if you call a function with more arguments than expected, doing so probably indicates that something is wrong. Octave also does not automatically report an error if a function is called with too few arguments, but any attempt to use a variable that has not been given a value will result in an error. To avoid such problems and to provide useful messages, we check for both possibilities and issue our own error message.

Built-in Function: nargin ()
Built-in Function: nargin (fcn_name)
  Within a function, return the number of arguments passed to the function. At the top level, return the number of command line arguments passed to Octave. If called with the optional argument fcn_name, return the maximum number of arguments the named function can accept, or -1 if the function accepts a variable number of arguments.

Built-in Variable: silent_functions
  If the value of `silent_functions` is nonzero, internal output from a function is suppressed. Otherwise, the results of expressions within a function body that are not terminated with a semicolon will have their values printed. The default value is 0.

  For example, if the function

      function f ()
        2 + 2
      endfunction

  is executed, Octave will either print ``ans = 4`' or nothing depending on the value of `silent_functions`.

Built-in Variable: warn_missing_semicolon
  If the value of this variable is nonzero, Octave will warn when statements in function definitions don't end in semicolons. The default value is 0.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.2 Multiple Return Values

Unlike many other computer languages, Octave allows you to define functions that return more than one value. The syntax for defining functions that return multiple values is

    function [ret-list] = name (arg-list)
      body
    endfunction

where name, arg-list, and body have the same meaning as before, and ret-list is a comma-separated list of variable names that will hold the values returned from the function. The list of return values must have at least one element. If ret-list has only one element, this form of the `function` statement is equivalent to the form described in the previous section.

Here is an example of a function that returns two values, the maximum element of a vector and the index of its first occurrence in the vector.

    function [max, idx] = vmax (v)
      idx = 1;
      max = v (idx);
      for i = 2:length (v)
        if (v (i) > max)
          max = v (i);
          idx = i;
        endif
      endfor
    endfunction

In this particular case, the two values could have been returned as elements of a single array, but that is not always possible or convenient. The values to be returned may not have compatible dimensions, and it is often desirable to give the individual return values distinct names.

In addition to setting `nargin` each time a function is called, Octave also automatically initializes `nargout` to the number of values that are expected to be returned. This allows you to write functions that behave differently depending on the number of values that the user of the function has requested. The implicit assignment to the built-in variable `ans` does not figure in the count of output arguments, so the value of `nargout` may be zero.

The `svd` and `lu` functions are examples of built-in functions that behave differently depending on the value of `nargout`.

It is possible to write functions that only set some return values. For example, calling the function

    function [x, y, z] = f ()
      x = 1;
      z = 2;
    endfunction

as

    [a, b, c] = f ()

produces:

    a = 1

    b = [](0x0)

    c = 2

along with a warning if the value of the built-in variable `warn_undefined_return_values` is nonzero.

Built-in Function: nargout ()
Built-in Function: nargout (fcn_name)
  Within a function, return the number of values the caller expects to receive. If called with the optional argument fcn_name, return the maximum number of values the named function can produce, or -1 if the function can produce a variable number of values.

  For example,

      f ()

  will cause `nargout` to return 0 inside the function `f` and

      [s, t] = f ()

  will cause `nargout` to return 2 inside the function `f`.

  At the top level, `nargout` is undefined.

Built-in Variable: warn_undefined_return_values
  If the value of `warn_undefined_return_values` is nonzero, print a warning if a function does not define all the values in the return list which are expected. The default value is 1.

Function File: nargchk (nargin_min, nargin_max, n)
  If n is in the range nargin_min through nargin_max inclusive, return the empty matrix. Otherwise, return a message indicating whether n is too large or too small.

  This is useful for checking to see that the number of arguments supplied to a function is within an acceptable range.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.3 Variable-length Argument Lists

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.4 Variable-length Return Lists

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.5 Returning From a Function

The body of a user-defined function can contain a `return` statement. This statement returns control to the rest of the Octave program. It looks like this:

    return

Unlike the `return` statement in C, Octave's `return` statement cannot be used to return a value from a function. Instead, you must assign values to the list of return variables that are part of the `function` statement. The `return` statement simply makes it easier to exit a function from a deeply nested loop or conditional statement.

Here is an example of a function that checks to see if any elements of a vector are nonzero.

    function retval = any_nonzero (v)
      retval = 0;
      for i = 1:length (v)
        if (v (i) != 0)
          retval = 1;
          return;
        endif
      endfor
      printf ("no nonzero elements found\n");
    endfunction

Note that this function could not have been written using the `break` statement to exit the loop once a nonzero value is found without adding extra logic to avoid printing the message if the vector does contain a nonzero element.

Keyword: return
  When Octave encounters the keyword `return` inside a function or script, it returns control to the caller immediately. At the top level, the return statement is ignored. A `return` statement is assumed at the end of every function definition.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.6 Function Files

Except for simple one-shot programs, it is not practical to have to define all the functions you need each time you need them. Instead, you will normally want to save them in a file so that you can easily edit them, and save them for use at a later time.

Octave does not require you to load function definitions from files before using them. You simply need to put the function definitions in a place where Octave can find them.

When Octave encounters an identifier that is undefined, it first looks for variables or functions that are already compiled and currently listed in its symbol table. If it fails to find a definition there, it searches the list of directories specified by the built-in variable `LOADPATH` for files ending in ``.m`' that have the same base name as the undefined identifier.(4) Once Octave finds a file with a name that matches, the contents of the file are read. If it defines a single function, it is compiled and executed. See section 13.7 Script Files, for more information about how you can define more than one function in a single file.

When Octave defines a function from a function file, it saves the full name of the file it read and the time stamp on the file. After that, it checks the time stamp on the file every time it needs the function. If the time stamp indicates that the file has changed since the last time it was read, Octave reads it again.

Checking the time stamp allows you to edit the definition of a function while Octave is running, and automatically use the new function definition without having to restart your Octave session. Checking the time stamp every time a function is used is rather inefficient, but it has to be done to ensure that the correct function definition is used.

To avoid degrading performance unnecessarily by checking the time stamps on functions that are not likely to change, Octave assumes that function files in the directory tree ``octave-home/share/octave/version/m`' will not change, so it doesn't have to check their time stamps every time the functions defined in those files are used. This is normally a very good assumption and provides a significant improvement in performance for the function files that are distributed with Octave.

If you know that your own function files will not change while you are running Octave, you can improve performance by setting the variable `ignore_function_time_stamp` to `"all"`, so that Octave will ignore the time stamps for all function files. Setting it to `"system"` gives the default behavior. If you set it to anything else, Octave will check the time stamps on all function files.

Built-in Variable: DEFAULT_LOADPATH
  A colon separated list of directories in which to search for function files. The value of this variable is automatically substituted for leading, trailing, or doubled colons that appear in the built-in variable `LOADPATH`.

Built-in Variable: LOADPATH
  A colon separated list of directories in which to search for function files. See section 13. Functions and Script Files. The value of `LOADPATH` overrides the environment variable `OCTAVE_PATH`. See section C. Installing Octave.

  `LOADPATH` is now handled in the same way as TeX handles `TEXINPUTS`. Leading, trailing, or doubled colons that appear in `LOADPATH` are replaced by the value of `DEFAULT_LOADPATH`. The default value of `LOADPATH` is `":"`, which tells Octave to search in the directories specified by `DEFAULT_LOADPATH`.

  In addition, if any path element ends in ``//`', that directory and all subdirectories it contains are searched recursively for function files. This can result in a slight delay as Octave caches the lists of files found in the `LOADPATH` the first time Octave searches for a function. After that, searching is usually much faster because Octave normally only needs to search its internal cache for files.

  To improve performance of recursive directory searching, it is best for each directory that is to be searched recursively to contain either additional subdirectories or function files, but not a mixture of both.

  See section 13.10 Organization of Functions Distributed with Octave, for a description of the function file directories that are distributed with Octave.

Built-in Function: rehash ()
  Reinitialize Octave's `LOADPATH` directory cache.

Built-in Function: file_in_loadpath (file)
Built-in Function: file_in_loadpath (file, "all")

  Return the absolute name name of file if it can be found in the list of directories specified by `LOADPATH`. If no file is found, return an empty matrix.

  If the first argument is a cell array of of strings, search each directory of the loadpath for element of the cell array and return the first that matches.

  If the second optional argument `"all"` is supplied, return a cell array containing the list of all files that have the same name in the path. If no files are found, return an empty cell array.

Built-in Variable: ignore_function_time_stamp
  This variable can be used to prevent Octave from making the system call `stat` each time it looks up functions defined in function files. If `ignore_function_time_stamp` to `"system"`, Octave will not automatically recompile function files in subdirectories of ``octave-home/lib/version`' if they have changed since they were last compiled, but will recompile other function files in the `LOADPATH` if they change. If set to `"all"`, Octave will not recompile any function files unless their definitions are removed with `clear`. For any other value of `ignore_function_time_stamp`, Octave will always check to see if functions defined in function files need to recompiled. The default value of `ignore_function_time_stamp` is `"system"`.

Built-in Variable: warn_function_name_clash
  If the value of `warn_function_name_clash` is nonzero, a warning is issued when Octave finds that the name of a function defined in a function file differs from the name of the file. (If the names disagree, the name declared inside the file is ignored.) If the value is 0, the warning is omitted. The default value is 1.

Built-in Variable: warn_future_time_stamp
  If the value of this variable is nonzero, Octave will print a warning if it finds a function file with a time stamp that is in the future.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.7 Script Files

A script file is a file containing (almost) any sequence of Octave commands. It is read and evaluated just as if you had typed each command at the Octave prompt, and provides a convenient way to perform a sequence of commands that do not logically belong inside a function.

Unlike a function file, a script file must not begin with the keyword `function`. If it does, Octave will assume that it is a function file, and that it defines a single function that should be evaluated as soon as it is defined.

A script file also differs from a function file in that the variables named in a script file are not local variables, but are in the same scope as the other variables that are visible on the command line.

Even though a script file may not begin with the `function` keyword, it is possible to define more than one function in a single script file and load (but not execute) all of them at once. To do this, the first token in the file (ignoring comments and other white space) must be something other than `function`. If you have no other statements to evaluate, you can use a statement that has no effect, like this:

    # Prevent Octave from thinking that this
    # is a function file:

    1;

    # Define function one:

    function one ()
      ...

To have Octave read and compile these functions into an internal form, you need to make sure that the file is in Octave's `LOADPATH`, then simply type the base name of the file that contains the commands. (Octave uses the same rules to search for script files as it does to search for function files.)

If the first token in a file (ignoring comments) is `function`, Octave will compile the function and try to execute it, printing a message warning about any non-whitespace characters that appear after the function definition.

Note that Octave does not try to look up the definition of any identifier until it needs to evaluate it. This means that Octave will compile the following statements if they appear in a script file, or are typed at the command line,

    # not a function file:
    1;
    function foo ()
      do_something ();
    endfunction
    function do_something ()
      do_something_else ();
    endfunction

even though the function `do_something` is not defined before it is referenced in the function `foo`. This is not an error because Octave does not need to resolve all symbols that are referenced by a function until the function is actually evaluated.

Since Octave doesn't look for definitions until they are needed, the following code will always print ``bar = 3`' whether it is typed directly on the command line, read from a script file, or is part of a function body, even if there is a function or script file called ``bar.m`' in Octave's `LOADPATH`.

    eval ("bar = 3");
    bar

Code like this appearing within a function body could fool Octave if definitions were resolved as the function was being compiled. It would be virtually impossible to make Octave clever enough to evaluate this code in a consistent fashion. The parser would have to be able to perform the call to `eval` at compile time, and that would be impossible unless all the references in the string to be evaluated could also be resolved, and requiring that would be too restrictive (the string might come from user input, or depend on things that are not known until the function is evaluated).

Although Octave normally executes commands from script files that have the name ``file.m`', you can use the function `source` to execute commands from any file.

Built-in Function: source (file)
  Parse and execute the contents of file. This is equivalent to executing commands from a script file, but without requiring the file to be named ``file.m`'.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.8 Dynamically Linked Functions

On some systems, Octave can dynamically load and execute functions written in C++. Octave can only directly call functions written in C++, but you can also load functions written in other languages by calling them from a simple wrapper function written in C++.

Here is an example of how to write a C++ function that Octave can load, with commentary. The source for this function is included in the source distributions of Octave, in the file ``examples/oregonator.cc`'. It defines the same set of differential equations that are used in the example problem of 23.1 Ordinary Differential Equations. By running that example and this one, we can compare the execution times to see what sort of increase in speed you can expect by using dynamically linked functions.

The function defined in ``oregonator.cc`' contains just 8 statements, and is not much different than the code defined in the corresponding M-file (also distributed with Octave in the file ``examples/oregonator.m`').

Here is the complete text of ``oregonator.cc`':

just

    #include <octave/oct.h>

    DEFUN_DLD (oregonator, args, ,
      "The `oregonator'.")
    {
      ColumnVector dx (3);

      ColumnVector x (args(0).vector_value ());

      dx(0) = 77.27 * (x(1) - x(0)*x(1) + x(0)
                       - 8.375e-06*pow (x(0), 2));

      dx(1) = (x(2) - x(0)*x(1) - x(1)) / 77.27;

      dx(2) = 0.161*(x(0) - x(2));

      return octave_value (dx);
    }

The first line of the file,

    #include <octave/oct.h>

includes declarations for all of Octave's internal functions that you will need. If you need other functions from the standard C++ or C libraries, you can include the necessary headers here.

The next two lines

    DEFUN_DLD (oregonator, args, ,
      "The `oregonator'.")

declares the function. The macro `DEFUN_DLD` and the macros that it depends on are defined in the files ``defun-dld.h`', ``defun.h`', and ``defun-int.h`' (these files are included in the header file ``octave/oct.h`').

Note that the third parameter to `DEFUN_DLD` (`nargout`) is not used, so it is omitted from the list of arguments in order to avoid the warning from gcc about an unused function parameter.

The next line,

    ColumnVector dx (3);

simply declares an object to store the right hand sides of the differential equation, and the statement

    ColumnVector x (args(0).vector_value ());

extracts a vector from the first input argument. The `vector_value` method is used so that the user of the function can pass either a row or column vector. The `ColumnVector` constructor is needed because the ODE class requires a column vector. The variable `args` is passed to functions defined with `DEFUN_DLD` as an `octave_value_list` object, which includes methods for getting the length of the list and extracting individual elements.

In this example, we don't check for errors, but that is not difficult. All of the Octave's built-in functions do some form of checking on their arguments, so you can check the source code for those functions for examples of various strategies for verifying that the correct number and types of arguments have been supplied.

The next statements

    dx(0) = 77.27 * (x(1) - x(0)*x(1) + x(0)
                     - 8.375e-06*pow (x(0), 2));

    dx(1) = (x(2) - x(0)*x(1) - x(1)) / 77.27;

    dx(2) = 0.161*(x(0) - x(2));

define the right-hand side of the differential equation. Finally, we can return `dx`:

    return octave_value (dx);

The actual return type is `octave_value_list`, but it is only necessary to convert the return type to an `octave_value` because there is a default constructor that can automatically create an object of that type from an `octave_value` object, so we can just use that instead.

To use this file, your version of Octave must support dynamic linking. To find out if it does, type the command `octave_config_info ("dld")` at the Octave prompt. Support for dynamic linking is included if this command returns 1.

To compile the example file, type the command ``mkoctfile oregonator.cc`' at the shell prompt. The script `mkoctfile` should have been installed along with Octave. Running it will create a file called ``oregonator.oct`' that can be loaded by Octave. To test the ``oregonator.oct`' file, start Octave and type the command

    oregonator ([1, 2, 3], 0)

at the Octave prompt. Octave should respond by printing

    ans =

       77.269353
       -0.012942
       -0.322000

You can now use the ``oregonator.oct`' file just as you would the `oregonator.m` file to solve the set of differential equations.

On a 133 MHz Pentium running Linux, Octave can solve the problem shown in 23.1 Ordinary Differential Equations, in about 1.4 seconds using the dynamically linked function, compared to about 19 seconds using the M-file. Similar decreases in execution time can be expected for other functions, particularly those that rely on functions like `lsode` that require user-supplied functions.

Just as for M-files, Octave will automatically reload a dynamically linked function when the file that defines it is more recent than the last time that the function was loaded. If more than one function is defined in a single ``.oct`' file, reloading the file may force other functions to be cleared and reloaded. If all the functions loaded from a given ``.oct`' file are cleared, Octave will automatically unload the ``.oct`' file.

Built-in Variable: warn_reload_forces_clear
  If several functions have been loaded from the same file, Octave must clear all the functions before any one of them can be reloaded. If `warn_reload_forces_clear`, Octave will warn you when this happens, and print a list of the additional functions that it is forced to clear.

Built-in Variable: variables_can_hide_functions
  If the value of this variable is nonzero, assignments to variables may hide previously defined functions of the same name. A negative value will cause Octave to print a warning, but allow the operation.

Additional examples for writing dynamically linked functions are available in the files in the ``src`' directory of the Octave distribution. Currently, this includes the files

    balance.cc   fft2.cc      inv.cc       qzval.cc
    chol.cc      filter.cc    log.cc       schur.cc
    colloc.cc    find.cc      lsode.cc     sort.cc
    dassl.cc     fsolve.cc    lu.cc        svd.cc
    det.cc       givens.cc    minmax.cc    syl.cc
    eig.cc       hess.cc      pinv.cc
    expm.cc      ifft.cc      qr.cc
    fft.cc       ifft2.cc     quad.cc

These files use the macro `DEFUN_DLD_BUILTIN` instead of `DEFUN_DLD`. The difference between these two macros is just that `DEFUN_DLD_BUILTIN` can define a built-in function that is not dynamically loaded if the operating system does not support dynamic linking. To define your own dynamically linked functions you should use `DEFUN_DLD`.

There is currently no detailed description of all the functions that you can call in a built-in function. For the time being, you will have to read the source code for Octave.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.9 Function Handles and Inline

This is a place holder for the description of function handles and inline functions.

13.9.1 Function Handles |  |
13.9.2 Inline Functions |  |

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 13.9.1 Function Handles

Built-in Function: functions (fcn_handle)
  Return a struct containing information about the function handle fcn_handle.

Built-in Function: func2str (fcn_handle)
  Return a string containing the name of the function referenced by the function handle fcn_handle.

Built-in Function: str2func (fcn_name)
  Return a function handle constructed from the string fcn_name.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 13.9.2 Inline Functions

Built-in Function: inline (str)
Built-in Function: inline (str, arg1, ...)
Built-in Function: inline (str, n)
  Create an inline function from the character string str. If called with a single argument, the arguments of the generated function are extracted from the function itself. The generated function arguments will then be in alphabetical order. It should be noted that i, and j are ignored as arguments due to the ambiguity between their use as a variable or their use as an inbuilt constant. All arguments followed by a parentheses are considered to be functions.

  If the second and subsequent arguments are character strings, they are the names of the arguments of the function.

  If the second argument is an integer n, the arguments are `"x"`, `"P1"`, ..., `"PN"`.

Built-in Function: argnames (fun)
  Return a cell array of character strings containing the names of the arguments of the inline function fun.

Built-in Function: formula (fun)
  Return a character string representing the inline function fun. Note that `char (fun)` is equivalent to `formula (fun)`.

Built-in Function: argnames (fun)
  Create a vectorized version of the inline function fun by replacing all occurrences of `*`, `/`, etc., with `.*`, `./`, etc.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 13.10 Organization of Functions Distributed with Octave

Many of Octave's standard functions are distributed as function files. They are loosely organized by topic, in subdirectories of ``octave-home/lib/octave/version/m`', to make it easier to find them.

The following is a list of all the function file subdirectories, and the types of functions you will find there.

``audio`'
  Functions for playing and recording sounds.

``control`'
  Functions for design and simulation of automatic control systems.

``elfun`'
  Elementary functions.

``general`'
  Miscellaneous matrix manipulations, like `flipud`, `rot90`, and `triu`, as well as other basic functions, like `ismatrix`, `nargchk`, etc.

``image`'
  Image processing tools. These functions require the X Window System.

``io`'
  Input-ouput functions.

``linear-algebra`'
  Functions for linear algebra.

``miscellaneous`'
  Functions that don't really belong anywhere else.

``plot`'
  A set of functions that implement the MATLAB-like plotting functions.

``polynomial`'
  Functions for manipulating polynomials.

``set`'
  Functions for creating and manipulating sets of unique values.

``signal`'
  Functions for signal processing applications.

``specfun`'
  Special functions.

``special-matrix`'
  Functions that create special matrix forms.

``startup`'
  Octave's system-wide startup file.

``statistics`'
  Statistical functions.

``strings`'
  Miscellaneous string-handling functions.

``time`'
  Functions related to time keeping.

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by John W. Eaton on May, 18 2005 using texi2html