Matlab
FromMFile
translate a MATLAB(R) .m source code file to Maple code
Calling Sequence
Parameters
Description
Examples
FromMFile(mfile)
FromMFile(mfile,mplfile)
FromMFile(mfile,mwfile)
FromMFile(mfile, ..., evaluate = false )
FromMFile(mfile, ..., overwrite = true )
FromMFile(mfile, ..., path = [paths] )
FromMFile(mfile, ..., string = false )
FromMFile(mfile, ..., worksheet = false )
FromMFile(mfile, ..., AddTranslator = false )
mfile
-
string specifying source .m file
mplfile
(optional) string specifying target command (.mpl) file
mwfile
(optional) string specifying target worksheet (.mw) file
evaluate
(optional) truefalse (default is false)
overwrite
(optional) truefalse (default is true)
path = paths
(optional) string or list of strings
string
(optional) truefalse
worksheet
AddTranslator
FromMFile converts a MATLAB® .m file into equivalent Maple input. The form of the converted output is controlled by one or more optional parameter.
When only one argument is given, FromMFile displays the code translation and evaluates it. Specifying the evaluate option will execute the translated code without first displaying the translated code. Specifying the string option will leave the translation as an unparsed string. It is recommended that translated code be reviewed first before evaluating it.
The second argument to FromMFile is the name of an output file. The target output can be a Maple worksheet file (.mw), or a Maple command file (.mpl). A worksheet file can be opened via File->Open in Maple's graphical user interface. A command file can be executed via Maple's read command.
When the second argument is a file name that ends in .mw, the output format is assumed to be Maple's xml worksheet format. To write a worksheet to a file name that doesn't end in .mw use the worksheet option. Similarly, use worksheet = false to write a command file using the extension .mw (but we don't recommend doing this).
By default overwrite is set to true. Thus, if the target mwfile or mplfile already exists, it will be silently overwritten. Specify overwrite = false to disallow writing over an existing file.
FromMFile will identify functions that are referenced in the current file, but implemented in a separate file. Consider the following two files:
% file r1.m: reference example 1/2
function [r] = r1( a, b )
r = r2(a) r3(b)
% file r2.m: reference example 2/2
function [r] = r2( a )
r = 2a
Executing FromMFile("r1.m",string) will show you that r2 was also translated in the same pass. The path option controls where the translator looks to find other .m files that implement commands referenced by the current .m file. By default the directory that contains mfile is in the search path. Setting path=[] prevents the translator from looking at any other file. One or more directories can be specified in the path= list.
When the AddTranslator option is set to false, the translator bypasses the AddTranslator extension mechanism and gives a general MATLAB® to Maple syntax translation without attempting to interpret the meaning of MATLAB® function calls.
For further discussion on MATLAB® to Maple translation see FromMatlab.
This function is part of the Matlab package, so it can be used in the short form FromMFile(..) only after executing the command with(Matlab). However, it can always be accessed through the long form of the command by using Matlab[FromMFile](..).
with⁡Matlab:
mfile≔cat⁡kernelopts⁡datadir,/help/Matlab/r1.m:
FromMFile⁡mfile,string,path=
r1 := proc( a, b ) local r; # file r1.m ?FromMfile function reference example 1/2 r := r2(a) . r3(b); return r; end proc;
FromMFile⁡mfile,string
r1 := proc( a, b ) local r; # file r1.m ?FromMfile function reference example 1/2 r := r2(a) . r3(b); return r; end proc; r2 := proc( a ) local r; # file r2.m ?FromMfile function reference example 2/2 r := 2 . a; return r; end proc;
mplfile≔FileTools:-TemporaryFile⁡r1,.mpl
mplfile≔/tmp/mpldoc3/r1yYoYxV9R.mpl
FromMFile⁡mfile,mplfile
mwfile≔FileTools:-TemporaryFile⁡r1,.mw
mwfile≔/tmp/mpldoc3/r1bx70dpPu.mw
FromMFile⁡mfile,mwfile
FromMFile⁡mfile,path=
Evaluating: r1 := proc( a, b ) local r; # file r1.m ?FromMfile function reference example 1/2 r := r2(a) . r3(b); return r; end proc;
proca,blocalr;r ≔ `.`⁡r2⁡a,r3⁡b;returnrend proc
r1⁡10,2
r2⁡10⁢r3⁡2
See Also
Matlab[AddTranslator]
Matlab[FromMatlab]
Download Help Document