Evaluate MATLAB expression and capture results
evaluates the MATLAB® code represented by results
= evalc(expression
)expression
and captures
anything that would normally be written to the Command Window in
results
.
Note
In most cases, using the evalc
function is less
efficient than using other MATLAB functions and language constructs, and the resulting code can
be more difficult to read and debug. For more information, see Alternatives to the eval Function.
[
additionally returns the outputs from results
,output1,...,outputN
] = evalc(expression
)expression
in the
specified variables.
When using evalc
, the functions
diary
, more
, and
input
are disabled.
If you use evalc
within an anonymous function, nested
function, or function that contains a nested function, the evaluated
expression
does not create any variables.
To allow the MATLAB parser to perform stricter checks on your code and avoid untrapped
errors and other unexpected behaviors, do not include output arguments in the
input to the evalc
function. For example, the statement
result = evalc(['output = ',expression])
is not
recommended.
Instead, specify output arguments to the evalc
function
to store the results of the evaluated expression. For example:
[result,output] = evalc(expression)