next up previous contents
Next: FEVAL Evaluate a Function Up: FreeMat Functions Previous: FreeMat Functions   Contents

Subsections

EVAL Evaluate a String

Usage

The eval function evaluates a string. The general syntax for its use is

   eval(s)

where s is the string to evaluate.

Example

Here are some examples of eval being used.

--> eval('a = 32')
a = 
  <int32>  - size: [1 1]
            32  
ans = 
  <double>  - size: []
  []

The primary use of the eval statement is to enable construction of expressions at run time.

--> s = ['b = a' ' + 2']
s = 
  <string>  - size: [1 9]
 b = a + 2
--> eval(s)
b = 
  <int32>  - size: [1 1]
            34  
ans = 
  <double>  - size: []
  []



2004-10-09