MATLAB and MAPLE symbol operation
ChinaMaker
Http://www.dytrol.com Dynamics and Control Technology Forum
An access MAPLE function
Maple command is very much, there are thousands, and it is very flexible to use. Considering the characteristics of this book, it will not be described in detail, only two of the most commonly used call formats: maple (statement) and maple ('function', arg1, arg2, ...). Function mapple is used to call the symbol calculation "Engine" and its huge library, where the input parameters can be symbol variables, or the value variable, the output structure, and the type of input parameters.
1.MAPLE (statement)
The functionality of this command is to pass the description of variables, expressions, and functions to the MATLAB symbol arithmetic engine - MAPLE V, by this engine to complete the computing task, return the characteristic result. This function is very strong, it can call all functions outside the image processing function. E.g:
The DSOLVE function is a function of the MAPLE to explain the differential equation, which may be a single differential equation or a differential equation group.
[Example 1]
>> MAPLE (DSOLVE ('(dy) ^ 2 y ^ 2 = 1', 'Y (0) = 0.5')))
ANS =
[SIN (T 1/6 * Pi)]
[COS (T 1/3 * Pi)]
2. MAPLE ('Function', Arg1, Arg2, ...)
This command is the standard form of MatLab calling the MAPLE function library. The input parameter function is the name of the function, arg1, arg2, ... is the parameter of the function function, and the number of parameters is determined in accordance with the function function.
[Example 2]
>> MAPLE ('MTAYLOR (EXP (X), [x = 0], 5)')
ANS =
MTAYLOR (EXP (X), [x = 0], 5)
Note: MAPLE Some functions are not automatically transferred to memory when Matlab starts. There is no decomposition in the above example, so you must read the MAPLE library when calling these functions.
[Example 3]
>> MAPLE ('Readlib (MTAYLOR)')
ANS =
PROC () Local F, K, V, M, N, S, T, W; option` Copyright (c) 1991 by ................
Then we re-call maple ('MTaylor (EXP (X), [X = 0], 5)') is as follows:
>> MAPLE ('MTAYLOR (EXP (X), [x = 0], 5)')
ANS =
1 x 1/2 * x ^ 2 1/6 * x ^ 3 1/24 * x ^ 4
Two run maple programs
In actual calculations, perhaps in general, we can run a single maple command to meet the requirements. In more complicated cases, we have to use the program written by Maple. In the former case, the previous section we have seen, and the latter case must have Procread and MAPLE fit to complete.
The following is explained by the method of cooperation examples.
[Example 4] Design for general implicit number f (x, y) = 0 derivative Y 'analytical procedure, and require that the program can be called like the original function of the mail.
Readers can refer to the following steps:
(1) Writing of the SRC source code file;
Write file Dytrol.src, store it in the work directory of MATLAB (can be placed in any directory you can search for Matlab), the file content is: dytrol: = proc (f)
Local EQ, DEQ, IMDERIV;
Eq: = 'EQ';
Eq: = f;
DEQ: = DIFF (EQ, X);
Readlib (isolate);
IMDERIV: = ISOLATE (DEQ, DIFF (Y (x), x));
END;
(2) Mount the source code into the maple workspace;
Run the following command to install Dytrol.src to the maple workspace:
PROCREAD ('Dytrol.src')% Convert SRC code to load maple workspace
Get it after running:
ANS =
Dytrol: = proc (f) local EQ, DEQ, IMDERIV; EQ: = 'EQ'; EQ: = F; DEQ: = DIFF (EQ, X); Readlib (ISOLATE); IMDERIV: = ISOLATE (DEQ, DIFF Y (x), x)) end
(3) Call the new function file that resides in memory by means of the maple command;
Enter the command in the MATLAB command window to get the result immediately, as follows:
>> S1 = maple ('Dytrol (x = sin (x y (x)));')
S2 = maple ('Dytrol (x ^ 2 * y (x) -log (2 * x) = sin (y (x)))')
S3 = maple ('Dytrol', 'SiN (x log (y (x))) = COS (Y (x))')
S1 =
DIFF (Y (x), x) = 1 / COS (x y (x)) - 1
S2 =
DIFF (Y (x), x) = (-2 * x * y (x) 1 / x) / (x ^ 2-cos (y (x))))
S3 =
DIFF (Y (x), x) = -COS (x log (y (x))) * y (x) / (COS (x log (x))) sin (y (x)) * y (x))
(4) Pre-editing Dytrol.SRC, becoming the Maple's internal code file, saved in the bin directory.
The above program has a disadvantage, and each time you start MATLAB, you must perform:
PROCREAD ('Dytrol.SRC')
In order to avoid this, follow these steps:
1) Clean the working space of Maple;
2) Put the source code to this space;
3) Convert the src file to the MAPLE's internal code M file and save it in the mallab / bin directory;
Take Dytrol.SRC as an example, the instruction set is as follows:
Clear MAplemex
PROCREAD ('Dytrol.src');
MAPLE ('Save (' Dytrol.m ')');
(5) Call the internal code file buffered by MAPLE.
MAPLE ('Read', 'Dytrol.m');
SS3 = maple ('DYTROL', 'SIN (X Log (Y (x))) = COS (Y (x))')
S3 =
DIFF (Y (x), x) = -COS (x log (y (x))) * y (x) / (COS (x log (x))) sin (y (x)) * Y (x)) Description: After the MAPLE source file is processed by the Procread, or the m file is read after the MAPLE is read into the workspace, it can be used at any time without having to read again each time.
12.3 small knot
Copyright: Dynamics and Control Technology Forum
http://www.dytrol.com (Reprinted Instructions)
This section mainly refers to how MATLAB calls the maple function, which is also an extension and enhancement of the MATLAB itself. The reason why MATLAB has such a strong symbolic operation, completely attributed to MathWork acquired MAPLE's kernels, developing MATLAB to the role of tiger.