translate a MATLAB(R) .m source code file to Maple code - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Mathematics : Numerical Computations : Matlab : Matlab/FromMFile

Matlab[FromMFile] - translate a MATLAB(R) .m source code file to Maple code

Calling Sequence




FromMFile(mfile, ..., evaluate = false )

FromMFile(mfile, ..., overwrite = true )

FromMFile(mfile, ..., path = [paths] )

FromMFile(mfile, ..., string = false )

FromMFile(mfile, ..., worksheet = false )

FromMFile(mfile, ..., AddTranslator = false )




string specifying source .m file



(optional) string specifying target command (.mpl) file



(optional) string specifying target worksheet (.mw) file



(optional) truefalse (default is false)



(optional) truefalse (default is true)

path = paths


(optional) string or list of strings



(optional) truefalse



(optional) truefalse



(optional) truefalse



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](..).





r1 := proc( a, b ) local r; # file r1.m ?FromMfile function reference example 1/2 r := r2(a) . r3(b); return r; end proc;



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;







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:=r2a.r3b;returnrend proc





See Also

Matlab[AddTranslator], Matlab[FromMatlab]

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam