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
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
>> x^3+cos(2*x)-1
ans =
3
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)
2
3 x
>> int(3*x^2)
>> factor(x^4+10*x^3+35*x^2+50*x+24)
(x + 4) (x + 3) (x + 2) (x + 1)
>> expand(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)
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)
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
[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]
The Matlab link lets you call on MATLAB® to perform calculations from the Maple environment, and return the results to Maple for further analysis.
with⁡Matlab
AddTranslator,FromMFile,FromMatlab,chol,closelink,defined,det,dimensions,eig,evalM,fft,getvar,inv,lu,ode15s,ode45,openlink,qr,setvar,size,square,transpose
evalM⁡why(16)
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.
Maple’s code generation feature can generate MATLAB® code from Maple expressions and procedures.
with⁡CodeGeneration:
Matlab⁡x+y⁢z−2⁢x⁢z,resultname=w
w = x + y * z - 2 * x * z;
Click to learn more about code generation in Maple.
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.
restart
withMatlab:
FromMatlab⁡[ 1 2 ; 3 4]
Evaluating: Matrix([[1, 2], [3, 4]] );
FromMatlab⁡A .* B
Evaluating:
A *~ B;
A⁢B
mfile ≔ " function x = mysumvarargin x = sumvarargin:":
FromMatlabmfile, evaluate=false:
See ?FromMatlab for further information.
Download Help Document