MATLAB Function Reference
  Go to function:
    Search    Help Desk 
eval    Examples   See Also

Interpret strings containing MATLAB expressions

Syntax

Description

a = eval('expression') returns the value of expression, a MATLAB expression, enclosed in single quotation marks. Create 'expression' by concatenating substrings and variables inside square brackets.

[a1,a2,a3...] = eval('expression') evaluates and returns the results in separate variables. Use of this syntax is recommended over:

which hides information from the MATLAB parser and can produce unexpected behavior.

eval(string,catchstring) provides the ability to catch errors. It executes string and returns if the operation was successful. If the operation generates an error, catchstring is evaluated before returning. Use lasterr to obtain the error string produced by string.

Examples

The loop

generates a sequence of 12 matrices named M1 through M12.

The next example runs a selected M-file script. Note that the strings making up the rows of matrix D must all have the same length.

See Also

feval       Function evaluation

lasterr     Last error message.



[ Previous | Help Desk | Next ]