Maple and MatLab
Maple can be used inside MatLab with modified commands. There is a package that is supposed to allow MatLab commands to be issued from within Maple.
Maple Inside Matlab
MatLab has a Symbolic Toolbox that uses Maple V Release 4 (which is 3 versions earlier than the most current Maple 7.0 ). MatLab has adapted a collection of the Maple commands to allow the user to perform symbolic calculations in MatLab without exiting the MatLab environment. These commands are in a slightly different format from Maple though they actually use the Maple environment. We will demonstrate a few of these commands in MatLab, but I do not have extensive experience, so suggest that the reader use the MatLab help to expand his/her knowledge of the capabilities of the Symbolic Toolbox . (Below the MatLab commands are after the MatLab command prompt >>)
In MatLab you declare your symbolic variables. For example,
>> syms a b x
Type in a function
>> f = exp(-b*x)*sin(a*x)
This can be differentiated and integrated
>> diff(f,x)
>> int(f,x)
Matlab can use Maple to sove differential equations. The dsolve command is slightly different from Maple, but it does allow easy access to the solution. The D2 gives two derivatives of y, and all expressions must be between single quotes to note a couple of differences from Maple.
>> dsolve('D2y + 4*Dy +5*y = 12*t^2', 'y(0)=1', 'Dy(0)=-2')
A more powerful use of Maple in MatLab is to allow Maple to perform symbolic computations on matrices, then these matrices could be further analyzed in MatLab. Below we show the generation of a Jacobian Matrix, then find the determinant of this matrix. This example is for the tranformation from rectangular to spherical coordinates. This operation performs differentiation of a column vector with respect to a row vector. Consider the transformation from Euclidean (x, y, z) to spherical coordinates as given by , , and . (We use the standard transformation in most Calculus books.) We will use the symbols r, t, and p for , , and , respectively.
To calculate the Jacobian matrix, J, of this transformation, use the jacobian function. The MatLab commands are
>> syms r t p
>> x = r*cos(t)*sin(p); y = r*sin(t)*sin(p); z = r*cos(p);
>> J = jacobian([x; y; z], [r t p])
J =
[ cos(t)*sin(p), -r*sin(t)*sin(p), r*cos(t)*cos(p)]
[ sin(t)*sin(p), r*cos(t)*sin(p), r*sin(t)*cos(p)]
[ cos(p), 0, -r*sin(p)]
The determinant of the Jacobian is used for the scaling the area from rectangular spherical coordinates in the integral. This is computed with the following command
>> det(J)
And can be made simple using the command
>> detJ = simple(det(J))
As noted above, we suggest that users of MatLab explore the opportunities that the Symbolic Toolbox provides them for expanding their use of MatLab. It should be noted that the Symbolic Toolbox is provided in the Student Version of MatLab automatically, but must be purchased separately with the main product, so may not be available at a particular location that has MatLab. (SDSU has a complete site license with all MatLab packages available on all computers with MatLab.)
MatLab Inside Maple
There is a very nice example on the Maple Help page showing the mixing of Maple and Matlab commands.
> with(Matlab):
This command tells Maple to go out to the computing environment and search for MatLab and a valid MatLab license. When these are confirmed, you can execute MatLab commands inside Maple. The Help example uses the MatLab Signal Processing Fourier Transform function, ft. We will simply download this example in class.