Previous Next Contents

21  Language and data translation tools

21.1   ascii string ascii conversions




CALLING SEQUENCE :

a=ascii(txt)
txt=ascii(a)



PARAMETERS :




DESCRIPTION :

This function convert Scilab string to a vector of ascii code or vector of ascii code to Scilab strings


See Also : code2str X, str2code X



21.2   excel2sci reads ascii Excel files




CALLING SEQUENCE :

M=excel2sci(fname [,sep])



PARAMETERS :




DESCRIPTION :

Given an ascii file created by Excel using "Text and comma" format exel2sci(fname) returns the corresponding Scilab matrix of strings. Use exel2sci(fname,sep ) for an other choice of separator.

Note: You may eval all or part ot M
using function evstr.


See Also : read X, evstr X



21.3   mfile2sci Matlab M_file to scilab translation function




CALLING SEQUENCE :

mfile2sci(M_file_path [,result_path [,Imode [,Recmode]]])



PARAMETERS :




DESCRIPTION :

mfile2sci, is Matlab M-file to Scilab function traduction tools. It tries whenever possible to replace call to Matlab functions by the equivalent scilab primitives and functions.

To translate 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

<function_name>.sci : the scilab equivalent of the m_file

<function_name>.cat : the scilab help file associated to the function

sci_
<function_name>.sci : the scilab function required to translate the calls to this Matlab M_file in other Matlab M_files. this function may be improved "by hand".

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.

Some other functions like plot, has no straightforward translation 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 began by "//!"


REMARKS :

This function is a still under developpement and is delivered as beta test.

Some Matlab4 basic functions are not yet translated. It is quite simple to add it. See
<SCIDIR>/macros/m2sci/README for more details.




KNOWN BUGS :




EXAMPLE :

//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']);
// translate it dor 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)



See Also : translatepaths X


Author : Serge Steer, INRIA



21.4   mtlb_load load variables from file with matlab4 format.




CALLING SEQUENCE :

 
mtlb_load fname
mtlb_load xxx.yyy
mtlb_load fname -ascii



PARAMETERS :




DESCRIPTION :

mtlb_load load variables on file with matlab4 formats.


See Also : mtlb_save X, save X, load X



21.5   mtlb_save save variables on file with matlab4 format.




CALLING SEQUENCE :

 
mtlb_save fname
mtlb_save fname X
mtlb_save fname X Y Z 
mtlb_save fname X Y Z  -ascii
mtlb_save fname X Y Z  -ascii -double 
mtlb_save fname X Y Z  -ascii -double -tabs



PARAMETERS :




DESCRIPTION :

mtlb_save save variables on file with matlab4 formats.


See Also : mtlb_load X, save X, load X



21.6   pol2tex convert polynomial to TeX format




CALLING SEQUENCE :

[y]=pol2tex(x)



PARAMETERS :




DESCRIPTION :

Latex source code for the polynomial x. (For use with texprint)


EXAMPLE :

s=poly(0,'s');
p=s^3+2*s-5;
pol2tex(p)



See Also : texprint X



21.7   sci2for scilab function to Fortran routine conversion




CALLING SEQUENCE :

txt=sci2for(fun,nam,vtps)



PARAMETERS :




DESCRIPTION :

The elements of the list vtps give the type and dimensions of variables of the calling sequence :
vtps(i)=list(typ,row_dim,col_dim)
where :

1 Generated code may use routines of scilab libraries and some others whose source code may be found in <SCIDIR>/util/sci2for.f


REMARKS :

This function is just a try. Only simple function may be translated. Many function calls have not yet Fortran equivalent, to add the translation of a new function call you may define a scilab function. whose name is f_<name of function>. see <SCIDIR>/macros/sci2for/f_*.sci files for examples.

The following keywords :
 work,iwork,ierr
 iw*  iiw*      
 ilbN   (N integer)          
may not appear in the function code.


See Also : function X



21.8   texprint TeX output of Scilab object




CALLING SEQUENCE :

[text]= texprint(a) 



PARAMETERS :




DESCRIPTION :

returns the Tex source code of the Scilab variable a. a is a matrix (constant, polynomial, rational) or a linear system (syslin list).


EXAMPLE :

s=poly(0,'s');
texprint([1/s,s^2])



See Also : pol2tex X, pol2str X



21.9   translatepaths translate a set of Matlab M_file directories to scilab




CALLING SEQUENCE :

translatepaths(dirs_path [,res_path])



PARAMETERS :




DESCRIPTION :

translatepaths, translate all Matlab M-file contained in a set of directories to Scilab functions. Each function is translated by mfile2sci.




See Also : mfile2sci X


Author : Serge Steer, INRIA


Previous Next Contents