MATLAB® Connectivity in Maple 16 - Maple Programming Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : System : Information : Updates : Maple 16 : updates/Maple16/MTM

MATLAB® Connectivity in Maple 16


Maple provides several different connectivity options for MATLAB®.  Some of these options have been enhanced for Maple 16.


Two-Way Integration between Maple and MATLAB®

Matlab Link

MATLAB® Code Generation

MATLAB® to Maple code translation

Two-Way Integration between Maple and MATLAB®

Maple commands, packages, assistants, and even the whole user interface is accessible from MATLAB®.  Using MATLAB® as your main interface you can use one of more than 200 native MATLAB® commands to do symbolic computation linking seamlessly to Maple's math engine.  Launch the Maple graphical interface from MATLAB® and interact with both programs as they share the same variables and state.  


The most basic symbolic object is a symbol. To start using Maple, create a sym object, x, in MATLAB®.  More complicated expressions can then be formed using your declared symbolic variable, x.


>> x = sym('x')

 x =



>> x^3+cos(2*x)-1


ans =



                               x  + cos(2 x) - 1


Symbolic expressions and equations can then, among other things, be differentiated, integrated, factored, and solved exactly using MATLAB® front-ends to Maple commands.   


>> diff(x^3)


ans =



                                     3 x


>> int(3*x^2)


ans =





>> factor(x^4+10*x^3+35*x^2+50*x+24)


ans =


                        (x + 4) (x + 3) (x + 2) (x + 1)


>> expand(ans)


ans =


                         4       3       2

                        x  + 10 x  + 35 x  + 50 x + 24


>> syms x y z

>> solve( 3*x+1*y+4*z-5, 8*x+19*y+11*z-94, x+y/4+z-11)          


ans =


        x: 39

        y: 72/13

        z: -382/13



New in Maple 16 is the ability to easily create symbolic matrices.  The sym command now accepts options for specifying the size and format of a matrix to be filled with symbolic entries.  


>> A = sym('A',[3 3])


A =


                            [A1_1    A1_2    A1_3]

                            [                    ]

                            [A2_1    A2_2    A2_3]

                            [                    ]

                            [A3_1    A3_2    A3_3]



The resulting matrices can be used to compute exact symbolic answers.  For example, the determinant of the above matrix as an equation can be calculated like this:


>> det(A)


ans =


  A1_1 A2_2 A3_3 - A1_1 A2_3 A3_2 + A2_1 A3_2 A1_3 - A2_1 A1_2 A3_3


         + A3_1 A1_2 A2_3 - A3_1 A2_2 A1_3



The format of the matrix entries can be customized using a string template.  Standard operations like matrix multiplication are known to the package and overloaded accordingly.


>> B = sym('B%d%d',[2 3])


B =


                              [B11    B12    B13]

                              [                 ]

                              [B21    B22    B23]

>> B * A


ans =


        [B11 A1_1 + B12 A2_1 + B13 A3_1 , B11 A1_2 + B12 A2_2 + B13 A3_2 ,


        B11 A1_3 + B12 A2_3 + B13 A3_3]


        [B21 A1_1 + B22 A2_1 + B23 A3_1 , B21 A1_2 + B22 A2_2 + B23 A3_2 ,


        B21 A1_3 + B22 A2_3 + B23 A3_3]


Matlab Link

The Matlab link lets you call on MATLAB® to perform calculations from the Maple environment, and return the results to Maple for further analysis.  






It should be obvious.


Maple commands seamlessly accept both MATLAB® and Maple data structures, and call MATLAB® behind the scenes to perform the calculation.


Maple 16 includes international language support.  It also keeps current with the latest versions, of MATLAB®,  R2011a and R2011b.


MATLAB® Code Generation

Maple’s code generation feature can generate MATLAB® code from Maple expressions and procedures.




w = x + y * z - 2 * x * z;


Click to learn more about code generation in Maple.


MATLAB® to Maple code translation

The FromMatlab command  helps you to convert your existing MATLAB® code into Maple syntax.  This can be used in new or expanded projects, or simply to see how a command you know from MATLAB® might be reproduced in Maple.




FromMatlab[ 1 2 ; 3 4]

Matrix([[1, 2], [3, 4]] );



FromMatlabA .* B


A *~ B;



mfile  " function x = mysumvarargin                            x = sumvarargin:":

FromMatlabmfile, evaluate=false:


See ?FromMatlab for further information.