MATLAB Application Program Interface Reference Help Desk

mexEvalString

Purpose

Execute a MATLAB command in the workspace of the caller

C Syntax

Arguments

command

A string containing the MATLAB command to execute.

Returns

0 if successful, and a nonzero value if unsuccessful.

Description

Call mexEvalString to invoke a MATLAB command in the workspace of the caller.

mexEvalString and mexCallMATLAB both execute MATLAB commands. However, mexCallMATLAB provides a mechanism for returning results (left-hand side arguments) back to the MEX-file; mexEvalString provides no way for return values to be passed back to the MEX-file.

All arguments that appear to the right of an equals sign in the command string must already be current variables of the caller's workspace.

Examples

Consider an M-file named FibSqr.m that invokes a MEX-file named CalcFib:

Suppose the CalcFib calculates the nth Fibonacci number. (MEX-files tend to calculate Fibonacci numbers significantly faster than M-files.) CalcFib calls mexEvalString to write the result into a variable named fib.

Invoking FibSqr yields

For an additional example, see mexEvalString.c in the mex subdirectory of the examples directory.

See Also

mexCallMATLAB



[ Previous | Help Desk | Next ]