GNU Octave Manual Version 3by John W. Eaton, David Bateman, Søren Hauberg Paperback (6"x9"), 568 pages ISBN 095461206X RRP £24.95 ($39.95) |

### 11.9.3 Inline Functions

An inline function is created from a string containing the function
body using the `inline`

function. The following code defines the
function f(x) = x^2 + 2.

f = inline("x^2 + 2");

After this it is possible to evaluate f at any x by
writing `f(x)`

.

__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 parenthesis 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"`

, ...,`"P`

.`N`"See also argnames, formula, vectorize

__Built-in Function:__**argnames***(*`fun`)- Return a cell array of character strings containing the names of
the arguments of the inline function
`fun`.See also inline, formula, vectorize

__Built-in Function:__**formula***(*`fun`)- Return a character string representing the inline function
`fun`. Note that`char (`

is equivalent to`fun`)`formula (`

.`fun`)See also argnames, inline, vectorize

__Built-in Function:__**vectorize***(*`fun`)- Create a vectorized version of the inline function
`fun`by replacing all occurrences of`*`

,`/`

, etc., with`.*`

,`./`

, etc.

ISBN 095461206X | GNU Octave Manual Version 3 | See the print edition |