3
<title>Inline Functions - Untitled</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="Untitled">
6
<meta name="generator" content="makeinfo 4.11">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Function-Handles-Inline-Functions-and-Anonymous-Functions.html#Function-Handles-Inline-Functions-and-Anonymous-Functions" title="Function Handles Inline Functions and Anonymous Functions">
9
<link rel="prev" href="Anonymous-Functions.html#Anonymous-Functions" title="Anonymous Functions">
10
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
11
<meta http-equiv="Content-Style-Type" content="text/css">
12
<style type="text/css"><!--
13
pre.display { font-family:inherit }
14
pre.format { font-family:inherit }
15
pre.smalldisplay { font-family:inherit; font-size:smaller }
16
pre.smallformat { font-family:inherit; font-size:smaller }
17
pre.smallexample { font-size:smaller }
18
pre.smalllisp { font-size:smaller }
19
span.sc { font-variant:small-caps }
20
span.roman { font-family:serif; font-weight:normal; }
21
span.sansserif { font-family:sans-serif; font-weight:normal; }
27
<a name="Inline-Functions"></a>
28
Previous: <a rel="previous" accesskey="p" href="Anonymous-Functions.html#Anonymous-Functions">Anonymous Functions</a>,
29
Up: <a rel="up" accesskey="u" href="Function-Handles-Inline-Functions-and-Anonymous-Functions.html#Function-Handles-Inline-Functions-and-Anonymous-Functions">Function Handles Inline Functions and Anonymous Functions</a>
33
<h4 class="subsection">11.9.3 Inline Functions</h4>
35
<p>An inline function is created from a string containing the function
36
body using the <code>inline</code> function. The following code defines the
37
function f(x) = x^2 + 2.
39
<pre class="example"> f = inline("x^2 + 2");
41
<p class="noindent">After this it is possible to evaluate f at any x by
42
writing <code>f(x)</code>.
44
<p><a name="doc_002dinline"></a>
47
— Built-in Function: <b>inline</b> (<var>str</var>)<var><a name="index-inline-612"></a></var><br>
48
— Built-in Function: <b>inline</b> (<var>str, arg1, <small class="dots">...</small></var>)<var><a name="index-inline-613"></a></var><br>
49
— Built-in Function: <b>inline</b> (<var>str, n</var>)<var><a name="index-inline-614"></a></var><br>
50
<blockquote><p>Create an inline function from the character string <var>str</var>.
51
If called with a single argument, the arguments of the generated
52
function are extracted from the function itself. The generated
53
function arguments will then be in alphabetical order. It should
54
be noted that i, and j are ignored as arguments due to the
55
ambiguity between their use as a variable or their use as an inbuilt
56
constant. All arguments followed by a parenthesis are considered
59
<p>If the second and subsequent arguments are character strings,
60
they are the names of the arguments of the function.
62
<p>If the second argument is an integer <var>n</var>, the arguments are
63
<code>"x"</code>, <code>"P1"</code>, <small class="dots">...</small>, <code>"P</code><var>N</var><code>"</code>.
67
<strong>See also:</strong> argnames, formula, vectorize.
68
</p></blockquote></div>
70
<p><a name="doc_002dargnames"></a>
73
— Built-in Function: <b>argnames</b> (<var>fun</var>)<var><a name="index-argnames-615"></a></var><br>
74
<blockquote><p>Return a cell array of character strings containing the names of
75
the arguments of the inline function <var>fun</var>.
79
<strong>See also:</strong> inline, formula, vectorize.
80
</p></blockquote></div>
82
<p><a name="doc_002dformula"></a>
85
— Built-in Function: <b>formula</b> (<var>fun</var>)<var><a name="index-formula-616"></a></var><br>
86
<blockquote><p>Return a character string representing the inline function <var>fun</var>.
87
Note that <code>char (</code><var>fun</var><code>)</code> is equivalent to
88
<code>formula (</code><var>fun</var><code>)</code>.
92
<strong>See also:</strong> argnames, inline, vectorize.
93
</p></blockquote></div>
95
<p><a name="doc_002dvectorize"></a>
98
— Built-in Function: <b>vectorize</b> (<var>fun</var>)<var><a name="index-vectorize-617"></a></var><br>
99
<blockquote><p>Create a vectorized version of the inline function <var>fun</var>
100
by replacing all occurrences of <code>*</code>, <code>/</code>, etc., with
101
<code>.*</code>, <code>./</code>, etc.
102
</p></blockquote></div>