1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>INLINE Construct Inline Function
</TITLE>
</HEAD>
<BODY>
<H2>INLINE Construct Inline Function
</H2>
<P>
Section: <A HREF=sec_function.html> Function Related Functions </A>
<H3>Usage</H3>
Constructs an inline function object. The syntax for its use is
either
<PRE>
y = inline(expr)
</PRE>
<P>
which uses the <code>symvar</code> function to identify the variables in the
expression, or the explicit form
<PRE>
y = inline(expr,var1,var2,...,varn)
</PRE>
<P>
where the variables are explicitly given. Note that inline functions
are only partially supported in FreeMat. If you need features of the
inline function that are not currently implemented, please file a
feature request at the FreeMat website.
<H3>Example</H3>
Here we construct an inline expression using the autodetection
of <code>symvar</code>
<PRE>
--> a = inline('x^2')
a =
inline function object
f(x) = x^2
--> a(3)
ans =
9
--> a(i)
ans =
-1.0000 + 0.0000i
</PRE>
<P>
In this case, we have multiple arguments (again, autodetected)
<PRE>
--> a = inline('x+y-cos(x+y)')
a =
inline function object
f(x,y) = x+y-cos(x+y)
--> a(pi,-pi)
ans =
-1
</PRE>
<P>
In this form, we specify which arguments we want to use (thereby
also specifying the order of the arguments
<PRE>
--> a = inline('x+t-sin(x)','x','t')
a =
inline function object
f(x,t) = x+t-sin(x)
--> a(0.5,1)
ans =
1.0206
</PRE>
<P>
Inline objects can also be used with <code>feval</code>
<PRE>
--> a = inline('cos(t)')
a =
inline function object
f(t) = cos(t)
--> feval(a,pi/2)
ans =
6.1230e-17
</PRE>
<P>
</BODY>
</HTML>
|