File: inline.mdc

package info (click to toggle)
freemat 4.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 141,800 kB
  • ctags: 14,082
  • sloc: ansic: 126,788; cpp: 62,046; python: 2,080; perl: 1,255; sh: 1,146; yacc: 1,019; lex: 239; makefile: 100
file content (84 lines) | stat: -rw-r--r-- 1,446 bytes parent folder | download | duplicates (2)
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

 Usage

Constructs an inline function object. The syntax for its use
is either

     y = inline(expr)

which uses the symvar function to identify the variables in
the expression, or the explicit form

     y = inline(expr,var1,var2,...,varn)

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.


 Example

Here we construct an inline expression using the
autodetection of symvar

  --> a = inline('x^2')

  a =
    inline function object
    f(x) = x^2
  --> a(3)

  ans =
   9

  --> a(i)

  ans =
    -1.0000 +  0.0000i

In this case, we have multiple arguments (again,
autodetected)

  --> a = inline('x+y-cos(x+y)')

  a =
    inline function object
    f(x,y) = x+y-cos(x+y)
  --> a(pi,-pi)

  ans =
   -1

In this form, we specify which arguments we want to use
(thereby also specifying the order of the arguments

  --> 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

Inline objects can also be used with feval

  --> a = inline('cos(t)')

  a =
    inline function object
    f(t) = cos(t)
  --> feval(a,pi/2)

  ans =
   6.1232e-17


* FreeMat_Documentation
* Function_Related_Functions
* Generated on Thu Jul 25 2013 17:17:14 for FreeMat by
  doxygen_ 1.8.1.1