Maple expressions can be evaluated in MATLAB using the , and commands. More information about these commands can be found in the help system by typing the following commands into the worksheet: , and
The command evaluates the expression in MATLAB. The command assigns a value to a variable in MATLAB, while the command returns the result stored in a MATLAB variable. The next two examples illustrate how to use these commands.
Example 1
The version of MATLAB with which the Maple-MATLAB connection is established can be determined using the and commands:
| (2) |
** Note: MATLAB returns the result of any expression in a variable called ans if no other variable has been specified by the user.
Example 2
The following example calculates the product of two Matrices, , in MATLAB and returns the result in Maple. The Matrices are defined in both Maple and MATLAB.
| (3) |
| (4) |
The Matrices defined in and are copied to the MATLAB variables and using the command.
:
The command can be used to ensure that the variables defined in and were actually stored
in the variable and . As expected, the command returns if a variable is defined in MATLAB, and otherwise.
=
=
The product of the two Matrices can now be calculated in MATLAB.
| (5) |