Overview of the Matlab Package

Calling Sequence


Matlab[command](arguments)
command(arguments)


Description


•

The Matlab package contains commands that communicate with MATLAB® and commands that translate MATLAB® code to Maple.


Secondary commands that use a connection to MATLAB® to evaluate domain specific functions in the MATLAB® environment include: Matlab[chol], Matlab[det], Matlab[dimensions], Matlab[eig], Matlab[fft], Matlab[inv], Matlab[lu], Matlab[ode15s], Matlab[ode45], Matlab[qr], Matlab[size], Matlab[square], and Matlab[transpose]. These are all built on the primary commands and simply move data back and forth between MATLAB® and Maple in order to evaluate a specific MATLAB® command. A properly configured MATLAB® installation is required to run these commands.


The Matlab package also contains commands that translate MATLAB® code into Maple. Refer to Matlab[FromMatlab], Matlab[FromMFile] and Matlab[AddTranslator]. These translation commands are entirely built within Maple and do not require MATLAB® to execute. The rest of this help page is not relevant to the translation commands.

•

To successfully invoke any command that requires communication with MATLAB® you must be on a platform that supports an identical MATLAB® architecture, and have a licensed MATLAB® executable in the path. For details, see Configuring a Computer for MATLAB(R).

•

Commands that communicate with MATLAB® via the Matlab package in Maple are collectively referred to as the "Matlab Link." Communication is initiated by Maple to evaluate commands in MATLAB® and possibly return a result. The reverse situation, where communication is initiated by MATLAB® to evaluate commands using Maple's computation engine is available via an addon toolbox, "The Maple Toolbox."

•

When communicating with MATLAB®, it is important to understand the difference between the following two types of matrices, both of which can be used in Matlab command calls.


(1) MatlabMatrix  Strings usually denote the name of a variable defined in MATLAB®. For example, the command Matlab[inv]("M") computes the inverse of the variable, M, which is defined in MATLAB®. If a variable M is also defined in Maple, the stated call will not affect it. The two calls, Matlab[det](M) and Matlab[det]("M") are very different.


(2) MapleMatrix  A MapleMatrix is any Maple expression that is equivalent to a fully defined Maple matrix; do not confuse MapleMatrix with the "matrix" type in Maple. A MapleMatrix can be an rtable (Array, Matrix or Vector), a table, or a constant (numeric or complex numeric or a symbolic constant such as Pi or infinity). All elements of the MapleMatrix must be of type constant.

•

Constants in Maple are represented as 1x1 matrices in MATLAB®. Command calls such as Matlab[det](543) are acceptable. Conversely, 1x1 matrices returned from MATLAB® are converted back to constants in Maple. This creates a special case when a Maple user actually wants a 1x1 matrix returned.

•

Most Matlab commands that have a return value return a constant or an rtable (that is, Array, Matrix, or Vector) with a hardware datatype (float[8] or complex[8]). The exceptions are Matlab[size] and Matlab[dimensions], which both return integer lists.

•

To compute intermediate steps in evaluation, Maple uses several MATLAB® variables. The names of these variables are prefixed by "result_for_maple"; for example, result_for_maple_1, result_for_maple_2, and so on.

•

Since conversion from nonfully defined (tablebased) arrays (matrices, vectors) to (rtablebased) Arrays (Matrices, Vectors) replaces the undefined elements with zeros, Matlab[setvar]() does this also. For example, Matlab[setvar]("x", array(1..2, [])); sets x=[0 0] in MATLAB®.

•

Onedimensional objects are treated as row or column vectors by MATLAB®, consistent with the Maple prettyprinter.

•

Note to Windows users: Maple opens only one MATLAB® session. This ensures that any MATLAB® variables defined in Maple apply to all worksheets in a session, even if you are running parallel server Maple.

•

Each command in the Matlab package can be accessed by using either the long form or the short form of the command name in the command calling sequence.



List of Matlab Package Commands


•

The following is a list of available commands.



Examples


To see the output from the examples, copy the examples to a worksheet and execute the worksheet. For information on accessing MATLAB® from Maple, see Matlab[setup].
>


Generate some data for analysis.
>


>


>


>


Add noise to the data.
>


>


>


>


Use MATLAB® to calculate the Fourier Transform.
>


Check whether this is a complex Vector.
>


Split it into parts.
>


>


How big is the returned value?
>


The length is the same as the defined variable 'num' .
To calculate the power spectrum, you need ft * conj(ft) /n. To do this in MATLAB®, first put 'ft' into the MATLAB® memory.
>


>


Calculate the desired result with evalM, ensuring the result is assigned to a variable so that the Matlab[getvar] command can be used.
>


Get the result.
>


Note that this result is not complex.
>


Plot the power spectrum. You must convert 'pwr' to a list in this case.
>


Due to symmetry, you must plot only the first half of the values.
>


>


There are two obvious frequencies. The dominant frequency is:
>


>


>


So the period is:
>


Find the secondary frequency. From the plot, you see that it is past t1.
>


>


>


So the secondary period is:
>


Note that T1 and T2 are close to the angle multipliers in the original equation, which is expected.

