1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) ???? - INRIA - Serge STEER
5 * Copyright (C) 2002-2004 - INRIA - Vincent COUVERT
6 * Copyright (C) 2018 - Samuel GOUGEON
8 * Copyright (C) 2012 - 2016 - Scilab Enterprises
10 * This file is hereby licensed under the terms of the GNU GPL v2.0,
11 * pursuant to article 5.3.4 of the CeCILL v.2.1.
12 * This file was originally licensed under the terms of the CeCILL v2.1,
13 * and continues to be available under such terms.
14 * For more information, see the COPYING file which you should have received
15 * along with this program.
18 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
19 xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
20 xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
21 xml:lang="en" xml:id="mfile2sci">
23 <refname>mfile2sci</refname>
24 <refpurpose>Matlab M-file to Scilab conversion function</refpurpose>
29 mfile2sci() // interactive GUI
30 mfile2sci(M_file_path)
31 mfile2sci(M_file_path, result_path )
32 mfile2sci(M_file_path, result_path, Recmode)
33 mfile2sci(M_file_path, result_path, Recmode, only_double)
34 mfile2sci(M_file_path, result_path, Recmode, only_double, verbose_mode)
35 mfile2sci(M_file_path, result_path, Recmode, only_double, verbose_mode, prettyprintoutput)
39 <title>Arguments</title>
42 <term>M_file_path</term>
44 <para>a character string which gives the path of Matlab M-file to convert</para>
48 <term>result_path</term>
51 a character string which gives the directory where the result has to be
52 written. Default value is current directory.
60 Boolean flag, used by <literal>translatepaths()</literal> function for
61 recursive conversion. Must be %F to convert a single mfile. Default value: %F
66 <term>only_double</term>
69 Boolean: If %T, mfile2sci() considers that numerical functions and operators
70 (like "+") are used only with numerical data. This excludes for instance
71 instructions like <literal>"ab" + "cd"</literal> (that then will be
72 kept as is instead of being converted into
73 <literal>asciimat("ab") + asciimat("cd")</literal>).
76 Default value: %F: All possible conversions are done.
81 <term>verbose_mode</term>
83 <para> display information mode</para>
87 <td>no information displayed</td>
92 information is written as comments in resulting SCI-file.
98 information is written as comments in resulting SCI-file
105 information is written as comments in resulting SCI-file,
106 in logfile and displayed in Scilab window. (Default value)
113 <term>prettyprintoutput</term>
115 <para>Boolean flag, if %T generated code is beautified. Default value: %F</para>
121 <title>Description</title>
123 M2SCI (and particularly mfile2sci) is Matlab M-file to Scilab function conversion tools.
124 It tries whenever possible to replace call to Matlab functions by the equivalent
125 Scilab primitives and functions.
128 To convert a Matlab M-file just enter the Scilab instruction:
129 <literal>mfile2sci(file)</literal>
132 where file is a character string giving the path name of the M-file.
135 <literal>mfile2sci(..)</literal> will then generate three files in the same directory:
140 <td><emphasis role="bold"><function-name>.sci</emphasis></td>
141 <td>The result of the translation of the M-file in Scilab language.</td>
144 <td><emphasis role="bold"><function-name>.cat</emphasis></td>
145 <td>the Scilab help file associated to the function</td>
148 <td><emphasis role="bold">sci_<function-name>.sci</emphasis></td>
150 The Scilab function required to convert the calls to this Matlab M-file
151 in other Matlab M-files. This function may be improved "by hand".
152 This function is only useful for conversion not for use of translated
159 Some functions like eye, ones, size, sum,... behave differently according to the
160 dimension of their arguments. When mfile2sci cannot infer dimensions it replaces
161 these function call by a call to an emulation function named mtlb_<function_name>.
162 For efficiency, these functions may be replaced by the proper scilab equivalent
164 To get information about replacement, enter:
165 <literal>help mtlb_<function_name></literal> in Scilab command window
168 Some other functions like plot, has no straightforward equivalent in scilab.
169 They are also replaced by an emulation function named
170 <literal>mtlb_<function_name></literal>.
173 When translation may be incorrect or may be improved mfile2sci adds a
174 comment which begins by "//!" (according to verbose_mode)
177 <literal>mfile2sci()</literal> without input argument launches a GUI allowing to
178 select a file/directory, and to configure and run the converter:
179 <programlisting role="example"><![CDATA[
185 <title>Examples</title>
186 <programlisting role="example"><![CDATA[
187 // Create a simple M-file
188 rot90m = ["function B = rot90(A,k)"
189 "if ~isa(A, ''double'')"
190 " error(''rot90: Wrong type for input argument #1: Real or complex matrix expected.'');"
197 " if ~isa(k, ''double'')"
198 " error(''rot90: Wrong type for input argument #2: A real expected.'');"
210 " B = A(m:-1:1,n:-1:1);"
217 mputl(rot90m, TMPDIR + "/rot90.m")
219 // Convert it to scilab language
220 mfile2sci(TMPDIR + "/rot90.m",TMPDIR)
223 editor(TMPDIR + "/rot90.sci")
225 // Compile it in scilab
226 exec(TMPDIR+'/rot90.sci')
233 <refsection role="see also">
234 <title>See also</title>
235 <simplelist type="inline">
237 <link linkend="translatepaths">translatepaths</link>
241 <refsection role="history">
242 <title>History</title>
245 <revnumber>6.0.2</revnumber>
247 The <varname>only_double</varname> option is now %F by default.