mfile2sci - Matlab M-file to Scilab conversion function
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.
To convert a Matlab M-file just enter the Scilab instruction: mfile2sci(file)
where file is a character string giving the path name of the M-file mfile2sci will generate three files in the same directory
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_<function_name>. For efficiency these functions may be replaced by the proper scilab equivalent instructions. To get informations about replacement, enter: help mtlb_<function_name> in Scilab command window
Some other functions like plot, has no straightforward équivalent in scilab. They are also replaced by an emulation function named mtlb_<function_name>.
When translation may be incorrect or may be improved mfile2sci adds a comment which begins by "//!" (according to verbose-mode)
When called without rhs, mfile2sci() launches a GUI to help to select a file/directory and options.
// Create a simple M-file write(TMPDIR+'/rot90.m',['function B = rot90(A,k)' '[m,n] = size(A);' 'if nargin == 1' ' k = 1;' 'else' ' 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']); // Convert it to scilab mfile2sci(TMPDIR+'/rot90.m',TMPDIR) // Show the new code write(%io(2),read(TMPDIR+'/rot90.sci',-1,1,'(a)')) // get it into scilab getf(TMPDIR+'/rot90.sci') // Execute it m=rand(4,2);rot90(m,1)