summaryrefslogtreecommitdiff
path: root/modules/m2sci/help/en_US/mfile2sci.xml
blob: bb51a175329fe06939d2066b13a1c913745d3d8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?xml version="1.0" encoding="UTF-8"?>
<!--
    * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
    * Copyright (C) ???? - INRIA - Serge STEER 
    * Copyright (C) 2002-2004 - INRIA - Vincent COUVERT 
    * 
    * This file must be used under the terms of the CeCILL.
    * This source file is licensed as described in the file COPYING, which
    * you should have received as part of this distribution.  The terms
    * are also available at    
    * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
    *
    -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="mfile2sci">
    <refnamediv>
        <refname>mfile2sci</refname>
        <refpurpose>Matlab M-file to Scilab conversion function</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Calling Sequence</title>
        <synopsis>mfile2sci([M-file-path [,result-path [,Recmode [,only-double [,verbose-mode [,prettyprintoutput]]]]]])</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>M-file-path</term>
                <listitem>
                    <para>a character string which gives the path of Matlab M-file to convert</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>result-path</term>
                <listitem>
                    <para>a character string which gives the directory where the result has to be written. Default value is current directory.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>Recmode</term>
                <listitem>
                    <para>Boolean flag, used by translatepaths function for recursive conversion. Must be %F to convert a single mfile. Default value : %f</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>only-double</term>
                <listitem>
                    <para>Boolean flag, if %T mfile2sci considers that numerical function have been used only with numerical data (no Scilab overloading function is needed). Default value: %T</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>verbose-mode</term>
                <listitem>
                    <para> display information mode</para>
                    <variablelist>
                        <varlistentry>
                            <term>0</term>
                            <listitem>
                                <para>no information displayed</para>
                            </listitem>
                        </varlistentry>
                        <varlistentry>
                            <term>1</term>
                            <listitem>
                                <para>information written as comment is resulting SCI-file</para>
                            </listitem>
                        </varlistentry>
                        <varlistentry>
                            <term>2</term>
                            <listitem>
                                <para>information written as comment is resulting SCI-file and in logfile</para>
                            </listitem>
                        </varlistentry>
                        <varlistentry>
                            <term>3</term>
                            <listitem>
                                <para>information written as comment is resulting SCI-file, in logfile and displayed in Scilab window</para>
                            </listitem>
                        </varlistentry>
                    </variablelist>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>prettyprintoutput</term>
                <listitem>
                    <para>Boolean flag, if %T generated code is beautified. Default value: %F</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            M2SCI (and particularly mfile2sci) is Matlab M-file to Scilab function conversion tools. It
            tries whenever possible to replace call to Matlab functions by the
            equivalent Scilab primitives and functions.
        </para>
        <para>
            To convert a Matlab M-file just enter the Scilab instruction:
            mfile2sci(file)
        </para>
        <para>
            where file is a character string giving the path name of the M-file
            mfile2sci will generate three files in the same directory
        </para>
        <variablelist>
            <varlistentry>
                <term>&lt;function-name&gt;.sci</term>
                <listitem>
                    <para>the Scilab equivalent of the M-file</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>&lt;function-name&gt;.cat</term>
                <listitem>
                    <para>the Scilab help file associated to the function</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>sci_&lt;function-name&gt;.sci</term>
                <listitem>
                    <para>the Scilab function required to convert the calls to this Matlab M-file in other Matlab M-files. This function may be improved "by hand". This function is only useful for conversion not for use of translated functions.</para>
                </listitem>
            </varlistentry>
        </variablelist>
        <para>
            Some functions like eye, ones, size, sum,... behave differently
            according to the dimension of their arguments. When mfile2sci cannot
            infer dimensions it replaces these function call by a call to an
            emulation function named mtlb_&lt;function_name&gt;. For efficiency these
            functions may be replaced by the proper scilab equivalent instructions.
            To get information about replacement, enter:
            help mtlb_&lt;function_name&gt; in Scilab command window
        </para>
        <para>
            Some other functions like plot, has no straightforward �quivalent in
            scilab. They are also replaced by an emulation function named
            mtlb_&lt;function_name&gt;.
        </para>
        <para>
            When translation may be incorrect or may be improved mfile2sci adds a
            comment which begins by "//!" (according to verbose-mode)
        </para>
        <para>
            When called without rhs, <literal>mfile2sci()</literal> launches a GUI to help to select a file/directory and options.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[ 
// Create a simple M-file
rot90m = ["function B = rot90(A,k)"
	"if ~isa(A, ''double'')"
	"    error(''rot90: Wrong type for input argument #1: Real or complex matrix expected.'');"
	"    return"
	"end"
	"[m,n] = size(A);"
	"if nargin == 1"
	"    k = 1;"
	"else"
	"    if ~isa(k, ''double'')"
	"        error(''rot90: Wrong type for input argument #2: A real expected.'');"
	"        return"
	"    end"
	"    k = rem(k,4);"
	"    if k < 0"
	"        k = k + 4;"
	"    end"
	"end"
	"if k == 1"
	"    A = A.'';"
	"    B = A(n:-1:1,:);"
	"elseif k == 2"
	"    B = A(m:-1:1,n:-1:1);"
	"elseif k == 3"
	"    B = A(m:-1:1,:);"
	"    B = B.'';"
	"else"
	"    B = A;"
	"end"];
mputl(rot90m, TMPDIR + "/rot90.m")

// Convert it to scilab
mfile2sci(TMPDIR + "/rot90.m",TMPDIR)

// Show the new code
mgetl(TMPDIR + "/rot90.sci")

// Load it into scilab
exec(TMPDIR+'/rot90.sci')

// Execute it
m=rand(4,2);
rot90(m,1)
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See Also</title>
        <simplelist type="inline">
            <member>
                <link linkend="translatepaths">translatepaths</link>
            </member>
        </simplelist>
    </refsection>
</refentry>