Foreword
|
This document contains a list of some Matlab basis functions and compare them
with the Scilab equivalent functions if there are. It gives the main differences
and gives examples of particular cases.
However not all Matlab and Scilab functions are described here.
Equivalents for operators and variables can be found at the end of this document.
Caution:
This document is not dedicated to explain how functions work.
Users can used online manuals of Matlab and Scilab for it.
How to use this HTML guide:
To have more details about functions and examples, clic on the "triangles" just
at the left of Matlab function name.
To have a more detailed index, clic on the letters and keywords.
|
|
|
|
Matlab |
A |
|
|
|
abs |
Absolute value and complex magnitude |
abs |
|
|
|
acosh |
Inverse hyperbolic cosine |
acosh |
|
|
|
acoth(A) |
Inverse hyperbolic cotangent |
atanh(1 ./A) |
|
In Matlab y=acoth(x) and Scilab y=atanh(1 ./x), for real elements of x outside the domain [-1,1], the complex part of Scilab y value is the opposite of Matlab y value. See atanh/. |
|
|
|
acot(A) |
Inverse cotangent |
atan(1 ./A) |
|
|
|
acsch(A) |
Inverse hyperbolic cosecant |
asinh(1 ./A) |
|
|
|
acsc(A) |
Inverse cosecant |
asin(1 ./A) |
|
|
|
all |
Test to determine if all elements are nonzero |
and |
|
Matlab all function can work with complexes, what Scilab and can not, so a call to abs function can be necessary when translating from Matlab to Scilab. ▹ B=all(A) ↔ B=and(A): If A is a matrix, all(A) is equivalent to all(A,1) in Matlab whereas in Scilab and(A) is a logical AND of all elements of A. If A is a multidimensional array then Matlab treats the values along the first non-singleton dimension, but Scilab returns logical AND of all elements of A. ▹ B=all(A,dim) ↔ B=and(A,dim): In Scilab dim=1 is equivalent to dim=''r'' and dim=2 is equivalent dim=''c''. In Matlab, dim can be greater then the number of dimension of A (in this case, B=A), in Scilab you will get an error message. |
y = all([1,1,0;1,0,1]) y = [1,0,0] y = all([1,1,0;1,0,1],1) y = [1,0,0]
|
y = and([1,1,0;1,0,1]) y = %F y = and([1,1,0;1,0,1],1) y = [%T,%F,%F]
|
|
|
|
angle(A) |
Phase angle |
atan(imag(A),real(A)) |
|
|
|
any |
Test to determine if any nonzeros elements |
or |
|
Matlab any function can work with complexes, what Scilab or can not, so a call to abs function can be necessary when translating from Matlab to Scilab. ▹ B=any(A) ↔ B=or(A): If A is a matrix, any(A) is equivalent to any(A,1) in Matlab whereas in Scilab or(A) is a logical OR of all elements of A. If A is a multidimensional array then Matlab treats the values along the first non-singleton dimension, but Scilab returns logical OR of all elements of A. ▹ B=any(A,dim) ↔ B=or(A,dim): In Scilab dim=1 is equivalent to dim=''r'' and dim=2 is equivalent dim=''c''. In Matlab, dim can be greater then the number of dimension of A (in this case, B=A), in Scilab you will get an error message. |
y = any([1,1,0;1,0,1]) y = [1,1,1] y = any([1,1,0;1,0,1],1) y = [1,1,1]
|
y = or([1,1,0;1,0,1]) y = %T y = or([1,1,0;1,0,1],1) y = [%T,%T,%T]
|
|
|
|
asech(A) |
Inverse hyperbolic secant |
acosh(1 ./A) |
|
|
|
asec(A) |
Inverse secant |
acos(1 ./A) |
|
|
|
asinh |
Inverse hyperbolic sine |
asinh |
|
|
|
asin |
Inverse sine |
asin |
|
In y=asin(x), for real elements of x outside the domain [-1,1], the complex part of Scilab y value is the opposite of Matlab y value. |
y = asin(2) y = 1.5708 - 1.3170i
|
y = asin(2) y = 1.5708 + 1.3170i
|
|
|
|
atan2 |
Four-quadrant inverse tangent |
atan2 |
|
Matlab atan2 function can work with complexes (in this case, complex part is ignored), what Scilab atan can not. |
|
|
|
atanh |
Inverse hyperbolic tangent |
atanh |
|
In y=atanh(x), for real elements of x outside the domain [-1,1], the complex part of Scilab y value is the opposite of Matlab y value. |
y = atanh(2) y = 0.5493 + 1.5708i
|
y = atanh(2) y = 0.5493061 - 1.5707963i
|
|
|
|
atan |
Two-quadrant inverse tangent |
atan |
|
|
|
|
Matlab |
B |
|
|
|
balance |
Diagonal scaling to improve eigenvalue accuracy |
balanc |
|
There is no equivalent for B=balance(A) in Scilab, balanc function does not work with only one output value. When used with two outputs, these functions return value in inverse order. |
[T,Ab] = balance(A)
|
[Ab,T] = balanc(A)
|
|
|
|
barh |
Bar histogram horizontal |
barh |
|
|
|
beep |
Produce a beep sound |
beep |
|
Scilab beep always returns a value but not Matlab function. |
|
|
|
besseli |
Modified Bessel functions of the first kind |
besseli |
|
Scilab besseli function can work with only one output argument, but the Matlab function can work with two outputs arguments. |
y = besseli(alpha,x) y = besseli(alpha,x,1) [y,ierr] = besseli(alpha,...)
|
y = besseli(alpha,x) y = besseli(alpha,x,ice),ice = 1 or ice = 2
|
|
|
|
besselj |
Bessel functions of the first kind |
besselj |
|
Scilab besselj function can work with only one output argument, but the Matlab function can work with two outputs arguments. |
y = besselj(alpha,x) y = besselj(alpha,x,1) [y,ierr] = besselj(alpha,...)
|
y = besselj(alpha,x) y = besselj(alpha,x,ice),ice = 1 or ice = 2
|
|
|
|
besselk |
Modified Bessel functions of the second kind |
besselk |
|
Scilab besselk function can work with only one output argument, but the Matlab function can work with two outputs arguments. |
y = besselk(alpha,x) y = besselk(alpha,x,1) [y,ierr] = besselk(alpha,...)
|
y = besselk(alpha,x) y = besselk(alpha,x,ice),ice = 1 or ice = 2
|
|
|
|
bessely |
Bessel functions of the second kind |
bessely |
|
Scilab bessely function can work with only one output argument, but the Matlab function can work with two outputs arguments. |
y = bessely(alpha,x) y = bessely(alpha,x,1) [y,ierr] = bessely(alpha,...)
|
y = bessely(alpha,x) y = bessely(alpha,x,ice),ice = 1 or ice = 2
|
|
|
|
beta |
Beta function |
beta |
|
Matlab beta function can work with only one scalar input an done not-scalar input parameter, but in Scilab both parameters must have the same size. |
A = 1; B = [1 2 3]; Y = beta(A,B);
|
A = 1; B = [1 2 3]; // So that A and B have the same size tmp = A;A = B;A(:) = tmp; Y = beta(A,B);
|
|
|
|
bin2dec |
Returns the integer corresponding to a Given binary representation |
bin2dec |
|
|
|
bitand |
The AND of two integers |
bitand |
|
|
|
bitcmp |
The binary complementary of an integer |
bitcmp |
|
|
|
bitget |
Gets the bit of an integer whose the positon is given in the input argument |
bitget |
|
|
|
bitor |
The OR of two integers |
bitor |
|
|
|
bitxor |
Returns the exclusive OR of two integers |
bitxor |
|
|
|
blanks |
A string of blanks |
No equivalent |
|
There is no Scilab equivalent function for Matlab box but it can be easyly replaced by Scilab equivalent instructions. |
A = ['xxx' blanks(20) 'yyy'];
|
A = "xxx"+part(" ",ones(1,20))+"yyy";
|
|
|
|
box |
Display axes border |
No equivalent |
|
There is no Scilab equivalent function for Matlab box but it can be easyly replaced by Scilab equivalent instructions. |
box on box off box box(h,'on') box(h,'off') box(h)
|
a = gca(); a.box = "on"; a.box = "off"; if a.box=="on" then a.box="off";else a.box="on";end; h.box = "on"; h.box = "off"; if h.box=="on" then h.box="off";else h.box="on";end;
|
|
|
|
break |
Terminate execution of a for loop or while loop |
break |
|
|
|
|
Matlab |
C |
|
|
|
case |
Case switch |
case |
|
In Matlab expression evaluated can be a cell, in this particular use, all values of cell are considered individually (similarly to a OR). In Scilab it can not be a cell (Matlab particularity can be replaced by others "case" or all switch/case statement can be replaced by a if/then/else statement.). |
|
|
|
cat |
Arrays concatenation |
cat |
|
|
|
cd |
Change/get working directory |
cd |
|
Note that cd .. does not work in Scilab, but it does in Matlab. In Scilab you can use cd(".."). |
|
|
|
cell2mat |
Convert a cell array into a matrix |
cell2mat |
|
|
|
cellstr |
Convert strings vector (or strings matrix) into a cell of strings |
cellstr |
|
|
|
cell |
Create cell array |
cell |
|
Note that in Matlab, input can contain complex values (in these cases, only real part of it is taken in account), what Scilab function do not tolerate. |
|
|
|
chol |
Cholesky factorization |
chol |
|
Scilab chol function can only have one output whereas Matlab one can have two ouputs. |
|
|
|
cla |
Clear current axes |
No equivalent |
|
▹ cla: Scilab equivalent could be a = gca();delete(a.children); but in this case, all current axes children will be deleted because there is no HandleVisibility property in Scilab graphics. ▹ cla reset: Scilab equivalent is a = gca();delete(a.children);. |
|
|
|
clc |
Clear Command Window |
clc([nblines]) |
|
Note that Scilab function allows to clear only a set of lines above the cursor using clc(nblines). Note that Scilab function can not be used in no window mode under Unix/Linux while Matlab one clears the terminal display as if you were using "clear" command. |
|
|
|
clear |
Remove items from workspace, freeing up system memory |
clear |
|
Scilab and Matlab clear functions are only equivalent when called using clear or clear name. ▹ clear global ...: Scilab equivalent for Matlab clear global [name] is clearglobal([name]). ▹ clear variables ...: Scilab equivalent for Matlab clear variables is simply clear. ▹ clear keyword ...: For all other keywords, there is no Scilab equivalent for Matlab clear call. |
|
|
|
clf |
Clear current figure window |
clf |
|
▹ clf: In this case, all current figure children will be deleted because there is no HandleVisibility property in Scilab graphics. ▹ fig_handle = clf: Scilab equivalent is be fig_handle = gcf();clf;. In this case, all current figure children will be deleted because there is no HandleVisibility property in Scilab graphics. |
|
|
|
clock |
Current time as a date vector |
No equivalent |
|
Even if there no equivalent for Matlab clock in Scilab, it can be emuled as shown in example. |
c = clock
|
w = getdate(); w(3:5) = []; w(6) = w(6)+w(7)/1000; c = w(1:6);
|
|
|
|
closereq |
Default figure close request function |
delete(gcf()) |
|
|
|
close |
Delete specified figure |
close ↔ xdel ↔ delete |
|
▹ close: If current figure is a uicontrol one, Scilab and Matlab close are equivalent. But if current figure is a graphic window, Scilab equivalent for Matlab close is delete(gcf()). ▹ close(h): If h is a uicontrol figure, Scilab and Matlab close(h) are equivalent. But if h is a graphic window, Scilab equivalent for Matlab close(h) is delete(h). ▹ close('all'): Scilab equivalent for Matlab close('all') is xdel(winsid()). ▹ close(name): There is no Scilab equivalent for Matlab close(name) however, mtlb_close can be an equivalent. ▹ close('all','hidden'): Scilab equivalent for Matlab close('all','hidden') is xdel(winsid()) but Scilab kills all figures even if they are hidden. |
|
|
|
colordef |
Set default property values to display different color schemes |
No equivalent |
|
▹ [h = ]mtlb_colordef(color_option): Scilab equivalent is fig = gcf();fig.background = -1;[h = fig]; if color_option is equal to "black" or "none" and fig = gcf();fig.background = -1;[h = fig]; else. ▹ [h = ]mtlb_colordef(fig,color_option): Considering fig is a graphics handle, Scilab equivalent is fig.background = -1;[h = fig]; if color_option is equal to "black" or "none" and fig.background = -2;[h = fig]; else. ▹ [h = ]mtlb_colordef('new',color_option): Scilab equivalent is fig=scf(max(winsid())+1);fig.background = -1;[h = fig]; if color_option is equal to "black" or "none" and fig=scf(max(winsid())+1);fig.background = -2;[h = fig]; else. |
|
|
|
complex |
Returns the complex form corresponding to the given real part and imaginary part |
complex |
|
|
|
conj |
Complex conjugate |
conj |
|
|
|
continue |
Keyword to pass control to the next iteration of a loop |
continue |
|
|
|
conv |
Convolution |
convol |
|
Scilab convol output value is always a row vector while Matlab conv output value is a column vector if at least one input is a column vector. To have a closer result, replace Matlab conv(A) by clean(convol(A)) in Scilab. |
|
|
|
cosh |
Hyperbolic cosine |
cosh |
|
|
|
coth |
Hyperbolic cotangent |
coth |
|
|
|
cputime |
Elapsed CPU time |
timer() |
|
|
|
csch(A) |
Hyperbolic cosecant |
1 ./sinh(A) |
|
|
|
csc(A) |
Cosecant |
1 ./sin(A) |
|
|
|
cumprod |
Cumulative product |
cumprod |
|
▹ C = cumprod(A): If A is a matrix, cumprod(A) is equivalent to cumprod(A,1) in Matlab whereas in Scilab cumprod(A) gives the cumulative product of all the entries of A taken columnwise. Actually, Matlab works on the first non-singleton dimension and Scilb does not. ▹ C = cumprod(A,dim): Matlab can work with dim greater than number of dimensions of A but Scilab can not, in this can use mtlb_cumprod instead. |
B = cumprod([1,2,3;4,5,6]) B = [1,2,3;4,10,18] B = cumprod([1,2,3;4,5,6],1) B = [1,2,3;4,10,18]
|
B = cumprod([1,2,3;4,5,6]) B = [1,8,120;4,40,720] B = cumprod([1,2,3;4,5,6],1) B = [1,2,3;4,10,18]
|
|
|
|
cumsum |
Cumulative sum |
cumsum |
|
▹ C=cumsum(A): If A is a matrix, cumsum(A) is equivalent to cumsum(A,1) in Matlab whereas in Scilab cumsum(A) gives the cumulative sum of all the entries of A taken columnwise. Actually, Matlab works on the first non-singleton dimension and Scilb does not. ▹ C = cumsum(A,dim): Matlab can work with dim greater than number of dimensions of A but Scilab can not, in this can use mtlb_cumsum instead. |
B = cumsum([1,2,3;4,5,6]) B=[1,2,3;5,7,9] B = cumsum([1,2,3;4,5,6],1) B=[1,2,3;5,7,9]
|
B = cumsum([1,2,3;4,5,6]) B=[1,7,15;5,12,21] B = cumsum([1,2,3;4,5,6],1) B=[1,2,3;5,7,9]
|
|
|
|
|
Matlab |
D |
|
|
|
date |
Current date string |
date() |
|
|
|
dec2bin |
The binary representation of a decimal number |
dec2bin |
|
|
|
dec2hex |
Decimal to hexadecimal number conversion |
dec2hex |
|
▹ Empty matrix input: In Matlab dec2hex returns "" when input is [] but Scilab dec2hex returns []. ▹ Complex inputs: In Matlab dec2hex automatically removes complex part of input but not in Scilab. ▹ Two inputs: In Matlab dec2hex can have two inputs, in Scilab mtlb_dec2hex emulates this case. |
|
|
|
delete |
Delete files or graphics objects |
mdelete ↔ delete |
|
▹ Files: When Matlab delete is used to delete a file, Scilab equivalent is mdelete. ▹ Graphics objects: When Matlab delete is used to delete a graphics object, Scilab equivalent is delete. Note that Scilab delete can delete a set of graphics handles is its input is a matrix of such objects. |
|
|
|
diag |
Diagonal including or extracting |
diag |
|
Due to the fact that strings or not considered in the same way in Matlab and in Scilab, results are not equal if A is a string matrix or vector in diag(A) or diag(A,k). Note that mtlb_diag can emulate this particularity in Scilab. |
B = diag('str') B = ['s ';' t ';' r']
|
B = diag(``str'') B = ``str'' B = mtlb_diag(``str'') B = [``s ``;'' t ``;'' r'']
|
|
|
|
diary |
Save session to a file |
diary |
|
When a filename is given to save environment, if this file exists, Scilab returns an error message while Matlab save environment at the end of existing file (append). Note that diary on and diary toggle exist only in Matlab. The equivalent for Matlab diary off is diary(0) in Scilab. |
|
|
|
diff |
Differences and approximate derivatives |
diff |
|
▹ Y = diff(X[,n]): For this kind of use of diff (dim parameter not given), Matlab works on the first non-singleton dimension of X what Scilab does not. In this case, Scilab considers dim to be "*" so that diff threats all values of X, what Matlab does not. ▹ Y = diff(X,n,dim): If dimension given by dim reaches 1 before n iterations have been done, Matlab switches to next non-singleton dimension, but Scilab does not, use mtlb_diff to get equivalent results...When n is greater than all existing dimensions of X, Matlab returns [] what Scilab may not give for all inputs...
|
|
|
|
dir |
Display directory listing |
dir |
|
When used in command window, Scilab and Matlab dir are equivalents. When result is stored in a value, Matlab returns a struture but Scilab returns a tlist. To get the same result, you can use mtlb_dir, note that in this case, hidden files are not get. |
|
|
|
display |
Overloaded method to display an object |
display |
|
|
|
disp |
Display text or array |
disp |
|
|
|
docopt |
Web browser for UNIX platforms |
No equivalent |
|
There no Scilab equivalent function, however, information about Web Browser used can be found using globalvariable %browsehelp. Thos variables exists under all platforms. |
|
|
|
doc |
Display online documentation |
help |
|
|
|
dos |
Execute a UNIX command and return result |
unix_g |
|
Output values order is inversed in Scilab and in Matlab. In Scilab use disp to emulate Matlab -echo option. |
[status,result] = dos(...)
|
[result,status] = unix_g(...)
|
|
|
|
double |
Conversion to double precision |
double |
|
In Matlab, this function returns a Boolean type value for a Boolean input whereas Scilab function returns a Double type value. |
|
|
|
drawnow |
Complete pending drawing events |
No equivalent |
|
In Scilab, drawing events are executed immediately. Scilab drawnow is different from Matlab one. |
|
|
|
|
Matlab |
E |
|
|
|
echo |
Echo lines during execution |
mode |
|
Scilab mode and Matlab echo are not exactly equivalents but they both change the information displayed during execution. Scilab mode has to be called inside a script or a function but Matlab echo can be called from prompt. However, some uses are equivalents such as: ▹ echo: is equivalent to Scilab mode(abs(mode()-1)) for scripts and non-compiled functions ▹ echo on: is equivalent to Scilab mode(1) for scripts and non-compiled functions ▹ echo off: is equivalent to Scilab mode(0) |
|
|
|
eig |
Find eigenvalues and eigenvectors |
spec ↔ bdiag |
|
▹ eig(A): Scilab equivalent for eig(A) is spec(A). Scilab eigen vector matrix can differ from Matlab one... ▹ eig(A,'nobalance'): There is no Scilab equivalent for 'nobalance' option. See examples... ▹ eig(A,B,flag): There is no Scilab equivalent for flag. |
d = eig(A,'balance') [V,D] = eig(A,'balance') d = eig(A,B) [V,D] = eig(A,B)
|
d = spec(A) [V,D] = bdiag(A+%i,1/%eps) [al,be] = spec(A); d = al./be; [al,be,V] = spec(A); D = spec(al./be);
|
|
|
|
elseif |
Conditionally execute statements |
elseif |
|
|
|
else |
Conditionally execute statements |
else |
|
|
|
end |
Terminate loops and conditionals |
end |
|
|
|
erfcx |
Scaled complementary error function |
erfcx |
|
|
|
erfc |
Complementary error function |
erfc |
|
|
|
error |
Display error messages |
error |
|
Scilab error function can only take one character string as input but Matlab function can take more than one character string as input and also numerical values... |
|
|
|
etime |
Elapsed time |
etime |
|
In Scilab, etime can be used with 6 and 10 value vectors but Matlab etime can only be used with 6 value vectors ([Year Month Day Hour Minute Second]). |
|
|
|
eval |
Execute a string containing an instruction/expression |
evstr ↔ execstr |
|
▹ Expression: When eval has to execute an expression then Scilab equivalent for eval is evstr ▹ Instruction: When eval has to execute an instruction with just one output value then Scilab equivalent for eval is evstr. If instruction has more than one output value then execstr has to be used as follows.When eval is used with two inputs then an equivalent can be found in examples below.
|
eval('1+1') eval('x=1+1') eval('[d1,d2]=size(1)') [d1,d2]=eval('size(1)') eval('1+1','1+2')
|
evstr('1+1') x = evstr('1+1') execstr('[d1,d2]=size(1)') execstr('[d1,d2]=size(1)') if execstr("1+1","errcatch") then execstr("1+2");end
|
|
|
|
exist |
Check if a variable or file exists |
exist |
|
Scilab exist function only works for variables, not for M-files or else... Scilab mtlb_exist function is a partial emulation for Matlab exist |
|
|
|
exit |
Ends current session |
exit |
|
|
|
expm |
Matrix exponential |
expm |
|
|
|
eye |
Identity matrix |
eye |
|
Note that in Matlab, A can contain complex values (in these cases, only real part of A is taken in account), what Scilab function do not tolerate. ▹ B=eye(A): If A is a scalar, then Matlab returns a A*A identity matrix but in Scilab you get a 1, use eye(A,A) to get the same matrix B. If A is a vector, Scilab and Matlab give the same B. Finally, if A is a matrix, in Scilab, B will be a matrix having the same size as A whereas in Matlab, you get an error message. |
B = eye(2) B = [1,0;0,1] B = eye(2,2) B = [1,0;0,1] B = eye([3,3]) B = [1,0,0;0,1,0;0,0,1]
|
B = eye(2) B = 1 B = eye(2,2) B = [1,0;0,1] B = eye([3,3]) B = [1,0]
|
|
|
|
|
Matlab |
F |
|
|
|
factor |
Prime numbers decomposition |
factor |
|
|
|
false |
False array |
No equivalent |
|
To get the same result in Scilab, use: zeros(...)==1. See zeros. |
|
|
|
fclose |
Close one or more open files |
mclose |
|
|
|
feof |
Test for end-of-file |
meof |
|
|
|
ferror |
Query about errors in file input or output |
mclearerr ↔ merror |
|
▹ ferror(fid): When Matlab ferror is called with just one input and one output, then Scilab equivalent is merror. ▹ ferror(fid,'clear'): When Matlab ferror is called with two inputs and just one output, then Scilab equivalent is mclearerr.For all other cases, there no equivalent in Scilab.
|
|
|
|
feval |
Function evaluation |
evstr ↔ execstr |
|
▹ One output: In this case Scilab evstr is an equivalent to feval, after modifying inputs such as in examples below. ▹ More than one output: In this case Scilab execstr is an equivalent to feval, after modifying inputs such as in examples below. |
[y1] = feval(@cos,0) [y1,y2] = feval(@size,1)
|
y1 = evstr("cos(0)") execstr("[y1,y2] = size(1)")
|
|
|
|
fftshift |
Shift zero-frequency component of discrete Fourier transform to center of spectrum |
fftshift |
|
▹ fftshift(A[,dim]): Due to the fact that strings or not considered in the same way in Matlab and in Scilab, results are not equal if A is a string matrix or vector in fftshift(A) or fftshift(A,dim). mtlb_fftshift can emulate this particularity in Scilab. ▹ fftshift(A,dim): In Matlab, dim can be greater than the number of dimensions of A but in Scilab you get an error message in this case. mtlb_fftshift can emulate this particularity in Scilab. |
Y = fftshift('str') Y = 'rst'
|
Y = fftshift('str') Y = 'str' Y = mtlb_fftshift('str') Y = 'rst'
|
|
|
|
fft(A[,...]) |
Discrete Fourier transform |
fft(A,-1[,...]) |
|
▹ Y = fft(X): If X is a vector then Scilab equivalent for Matlab fft(X) is fft(X,-1). If X is a matrix then Scilab equivalent for Matlab fft(X) is fft(X,-1,2,1). ▹ Y = fft(X,n) / Y = fft(X,n,dim) / Y = fft(X,[],dim): There is no Scilab equivalent for all these Matlab uses of fft, in these cases, use mtlb_fft instead. |
|
|
|
fgetl |
Read line(s) from file, discard newline character |
mgetl |
|
Matlab fgetl reads file line per line while Scilab mgetl allows to read the whole file. Matlab fgetl returns -1 if it could not read a line in file but Scilab mgetl returns an empty string is this case. You can used meof to check if End Of File has been reached. |
|
|
|
fgets |
Read line from file, keep newline character |
fgetstr |
|
Input parameter order is inversed in Scilab compared to Matlab. |
fgets(fid,n)
|
fgetstr(n,fid)
|
|
|
|
fileparts |
Return filename parts |
fileparts |
|
Scilab function does not get file version but Matlab one does. Scilab function can take a second input parameter specifying the output value we want to get saying: "path", "fname" or "extension". |
|
|
|
filesep |
Return the directory separator for this platform |
No equivalent |
|
There is no Scilab function equivalent to Matlab filesep but the same output can be obtained with pathconvert("/"). |
|
|
|
findstr |
Find one string within another |
No equivalent |
|
There is no equivalent for findstr in Scilab, but an emulation function has been written: mtlb_findstr. Scilab strindex function is very similar to findstr but do not consider the size of the strings passed as parameters. strindex can replace findstr only if findstr can be replaced by strfind in Matlab. |
|
|
|
find |
Find indices and values of nonzero elements |
find |
|
Matlab function can work with complex values what is not possible in Scilab, however, using abs it is very easy to have the same results. Note that Scilab function can only return two output values and Matlab one can return a third value that can be computed according to the first two output matrices as explained in Matlab help. For example, in [i,j,v]=find(X), v is equal to: X(i+(j-1))*size(X,1). Another great difference between Scilab and Matlab is that Matlab returns column vectors of indices when X is a column vector or a matrix but Scilab always returns row vectors. For this kind of input, use matrix to get the same output value...what is done mtlb_find() |
|
|
|
fix |
Round towards zero |
fix |
|
|
|
fliplr(A) |
Flip matrix in left/right direction |
A(:,$:-1:1) |
|
Due to the fact that Scilab and Matlab do not consider character string in the same way, result is different for this kind of input, in this case, use mtlb_fliplr instead. |
|
|
|
flipud(A) |
Flip matrix in up/down direction |
A($:-1:1,:) |
|
|
|
fopen |
Open a file or obtain information about open files |
mopen |
|
▹ Access permission: Matlab offers two permissions options not supported by Scilab: W and A (for tape drives) ▹ Input values: In Matlab, fopen('all') lists all opened files, in Scilab, this type of call for fopen does not exist. You can also use fopen in Matlab to get informations on a file identifier (fopen(fid)), this case is not implemented in Scilab. ▹ Machine format: Note that Scilab does not support machine format values as input or output.Matlab fopen can return an error message but not Scilab mopen, moreover, returned file identifier is -1 in case of error in Matlab but does not exist in this case in Scilab, so an emulation function has been written mtlb_fopen.
|
|
|
|
format |
Control display format for output |
format |
|
Some Matlab formats have no Scilab equivalent, see examples below. |
format format + format bank format compact format hex format long format long e format long g format loose format rat format short format short e format short g
|
format("v",6) format(6) No equivalent for: format "bank" No equivalent for: format "compact" No equivalent for: format "hex" format(16) format("e",16) format("e",16) No equivalent for: format "loose" No equivalent for: format "rat" format(6) format("e",6) format("e",6)
|
|
|
|
for |
Repeat statements a specific number of times |
for |
|
The variable used as loop index is clear in Scilab if all iterations have been made but is not clear if llop is ended by a break. In Matlab, this variable is never cleared. |
|
|
|
fprintf |
Write formatted data to file |
No equivalent |
|
There is no equivalent function for Matlab fprintf in Scilab but an emulation function has been written: mtlb_fprintf. This function probably not allows all Matlab fprintf possibilities... |
|
|
|
fread |
Read binary data to a file |
No equivalent |
|
There is no equivalent function for Matlab fread in Scilab but an emulation function has been written: mtlb_fread. This function probably not allows all Matlab fread possibilities (skip parameter is ignored...). |
|
|
|
frewind(fid) |
Move the file position indicator to the beginning of an open file |
mseek("0",fid) |
|
|
|
fscanf |
Read formatted data to file |
No equivalent |
|
There is no equivalent function for Matlab fscanf in Scilab but an emulation function has been written: mtlb_fscanf. This function probably not allows all Matlab fscanf possibilities... |
|
|
|
fseek |
Set file position indicator |
mseek |
|
Scilab and Matlab functions differ by the flag which indicate the origin of the position indicator, see examples below. Note that order of input value is different... |
File beginning: fseek(fid,offset,'bof') fseek(fid,offset,-1) Current position: fseek(fid,offset,'cof') fseek(fid,offset,0) File end: fseek(fid,offset,'eof') fseek(fid,offset,1)
|
File beginning: fseek(offset,fid,"set") Current position: fseek(offset,fid,"cur") File end: fseek(offset,fid,"end")
|
|
|
|
ftell |
Get file position indicator |
mtell |
|
|
|
fullfile |
Build a full filename from parts |
fullfile |
|
|
|
full |
Convert sparse matrix to full matrix |
full |
|
|
|
function |
Function definition |
function |
|
|
|
fwrite |
Write binary data to a file |
No equivalent |
|
There is no equivalent function for Matlab fwrite in Scilab but an emulation function has been written: mtlb_fwrite. This function probably not allows all Matlab fwrite possibilities (skip parameter is ignored...). |
|
|
|
|
Matlab |
G |
|
|
|
gammaln |
Logarithm of gamma function |
gammaln |
|
|
|
gamma |
Gamma function |
gamma |
|
|
|
getenv |
Get environment variable |
getenv |
|
Scilab getenv allows to set the string that will be returned if environment variable we want to get does not exist, but not Matlab function. |
|
|
|
global |
Define a global variable |
global |
|
|
|
graymon |
Set graphics defaults for gray-scale monitors |
No equivalent |
|
This Matlab function can be replaced in Scilab by: set(gdf(),"color_map",[0.75,0.5,0.25]'*ones(1,3)). |
|
|
|
grid |
Grid lines for two- and three-dimensional plots |
No equivalent |
|
There is no minor grid in Scilab. There is no equivalent function for Matlab grid function in Scilab but it has equivalents: ▹ grid on: may be replaced by set(gca(),"grid",[1 1]) ▹ grid off: may be replaced by set(gca(),"auto_clear",[-1 -1]) ▹ grid minor: can be emuled in Scilab by mtlb_hold but all grids are toggled ▹ grid: can be emuled in Scilab by mtlb_hold ▹ grid(axes_handle,'on'): may be replaced by axes_handle.grid=[1 1] ▹ grid(axes_handle,'off'): may be replaced by axes_handle.grid=[-1 -1] ▹ grid(axes_handle,'minor'): can be emuled in Scilab by mtlb_hold but all grids are toggled ▹ grid(axes_handle): can be emuled in Scilab by mtlb_hold(axes_handle) |
|
|
|
|
Matlab |
H |
|
|
|
hankel |
Hankel matrix |
hank |
|
The main difference between Scilab and Matlab function is that they do not use the same input values to build an Hankel matrix. If in Matlab, you just have to give a column vector (and eventually a row vector), Scilab function requires the size of the Hankel matrix to build and a covariance sequence vector for this matrix. (See syntax below) |
H1 = hankel(C1) H2 = hankel(C2,R2)
|
N1 = size(C1,"*"); COV1 = [matrix(C1,1,-1),zeros(1,N1)]; H1 = hank(N1,N1,COV1); M2 = size(C2,"*"); N2 = size(R2,"*"); COV2 = [matrix(C2,1,-1),matrix(R2(2:$),1,-1)]; H2 = hank(M2,N2,COV2);
|
|
|
|
helpbrowser |
Display Help browser for access to full online documentation |
help |
|
|
|
helpdesk |
Display Help browser |
help |
|
|
|
helpwin |
Provide access to and display help for all functions |
help |
|
|
|
help |
Display help |
help |
|
In Scilab you can not get help on a toolbox, only on a function... Scilab equivalent for Matlab help syntax is help("names"). |
|
|
|
hess |
Hessenberg form of a matrix |
hess |
|
|
|
hold |
Hold current graph |
No equivalent |
|
There is no equivalent function for Matlab hold function in Scilab but it has equivalents: ▹ hold on: may be replaced by set(gca(),"auto_clear","off") ▹ hold off: may be replaced by set(gca(),"auto_clear","on") ▹ hold: can be emuled in Scilab by mtlb_hold |
|
|
|
home |
Move the cursor to the upper left corner of the Command Window |
tohome |
|
Note that Matlab function has no effect in no window mode under Unix/Linux while Scilab one clears the terminal display as if you were using "clear" command. |
|
|
|
horzcat |
Horizontal concatenation |
No equivalent |
|
Scilab equivalent for Matlab horzcat(A1,A2,...,An) is [A1,A2,...,An] if all Ai are not character strings, else, Scilab equivalent is A1+A2+...+An. |
|
|
|
|
Matlab |
I |
|
|
|
ifft(A[,...]) |
Inverse discrete Fourier transform |
fft(A,1[,...]) |
|
▹ Y = ifft(X): If X is a vector then Scilab equivalent for Matlab ifft(X) is fft(X,1). If X is a matrix then Scilab equivalent for Matlab ifft(X) is fft(X,1,2,1). ▹ Y = ifft(X,n) / Y = ifft(X,n,dim) / Y = ifft(X,[],dim): There is no Scilab equivalent for all these Matlab uses of ifft, in these cases, use mtlb_ifft instead. |
|
|
|
if |
Conditionally execute statements |
if |
|
In Scilab condition can be ended by then but not in Matlab. |
|
|
|
imag |
Complex imaginary part |
imag |
|
|
|
input |
Request user input |
input |
|
|
|
int16 |
Convert to 16-bit signed integer |
int16 |
|
For infinite and NaNs values, Scilab and Matlab int16 return different values. |
A = int16(inf) A = 32767 A = int16(-inf) A = -32768 A = int16(nan) A = 0
|
A = int16(%inf) A = -32768 A = int16(-%inf) A = -32768 A = int16(%nan) A = -32768
|
|
|
|
int32 |
Convert to 32-bit signed integer |
int32 |
|
For infinite and NaNs values, Scilab and Matlab int32 return different values. |
A = int32(inf) A = 2147483647 A = int32(-inf) A = -2147483648 A = int32(nan) A = 0
|
A = int32(%inf) A = -2147483648 A = int32(-%inf) A = -2147483648 A = int32(%nan) A = -2147483648
|
|
|
|
int8 |
Convert to 8-bit signed integer |
int8 |
|
For infinite values, Scilab and Matlab int8 return different values. |
A = int8(inf) A = 127 A = int8(-inf) A = -128
|
A = int8(%inf) A = 0 A = int8(-%inf) A = 0
|
|
|
|
interp1 |
One_dimension interpolation function |
interp1 |
|
Scilab interp1 function doesn't work with the pchip interpolation method. |
|
|
|
isa |
Detect an object of a given type |
No equivalent |
|
There is no equivalent function for Matlab isa function in Scilab but it can be replaced by equivalent syntaxes as shown is examples. |
a = isa(x,'logical') b = isa(x,'char') c = isa(x,'numeric') d = isa(x,'int8') e = isa(x,'uint8') f = isa(x,'int16') g = isa(x,'uint16') h = isa(x,'int32') k = isa(x,'uint32') l = isa(x,'single') m = isa(x,'double') n = isa(x,'cell') o = isa(x,'struct') p = isa(x,'function_handle') q = isa(x,'sparse') r = isa(x,'lti')
|
a = type(x)==4; b = type(x)==10; c = or(type(x)==[1,5,8]); d = typeof(x)=="int8"; e = typeof(x)=="uint8"; f = typeof(x)=="int16"; g = typeof(x)=="uint16"; h = typeof(x)=="int32"; k = typeof(x)=="uint32"; l = type(x)==1; m = type(x)==1; n = typeof(x)=="ce"; o = typeof(x)=="st"; p = type(x)==13; q = type(x)==5; r = typeof(x)=="state-space";
|
|
|
|
iscell(A) |
Determine if input is a cell array |
typeof(A)=="ce" |
|
|
|
ischar(A) |
Determine if item is a character array |
type(A)==10 |
|
|
|
isdir |
Determine if item is a directory |
isdir |
|
|
|
isempty |
True for empty matrix |
isempty |
|
|
|
isequal |
Determine if arrays are numerically equal |
isequal |
|
In Scilab, struct fields must be in the same order so that structs can be equal but not in Matlab. |
|
|
|
isfield |
Determine if input is a structure array field |
No equivalent |
|
There is no Scilab equivalent function for Matlab tf=isfield(A,field) but there are equivalent instructions: ▹ If A is not a structure and/or field is not a character string: Scilab equivalent is %F. ▹ If A is a structure and field is a character string: Scilab equivalent is allfields=getfield(1,A);tf=or(allfields(3:$)==field);. |
|
|
|
isfinite |
True for finite elements |
No equivalent |
|
There is no equivalent function for Matlab isfinite function in Scilab but it can be emuled by: abs(A)<%Inf |
|
|
|
isglobal |
Determine if item is a global variable |
isglobal |
|
|
|
ishandle(A) |
Determines if values are valid graphics object handles |
type(A)==9 |
|
|
|
ishold |
Return hold state |
No equivalent |
|
There is no equivalent function for Matlab ishold function in Scilab but it can be emuled by: get(gca(),"auto_clear")=="off";. |
|
|
|
isinf |
True for infinite elements |
isinf |
|
|
|
isinteger(A) |
Detect whether an array has integer data type |
type(A)==8 |
|
|
|
isletter |
True for letters of the alphabet |
No equivalent |
|
There is no equivalent function to Matlab isletter function in Scilab. However it can be replaced as follows. Using mtlb_isletter will give a prettier code. |
tf = isletter(A)
|
If A is a String matrix: tf = ((asciimat(A)65) & (asciimat(A)90)) ((asciimat(A)97) & (asciimat(A)122)) If A is not a String matrix: tf = zeros(A)
|
|
|
|
islogical(A) |
Determine if item is a logical array |
No equivalent |
|
There is no equivalent function for Matlab islogical function in Scilab but it can be emuled by: or(type(A)==[4,6]). |
|
|
|
isnan |
Detect NaN elements of an array |
isnan |
|
|
|
isnumeric(A) |
Determine if input is a numeric array |
No equivalent |
|
There is no equivalent function for Matlab isnumeric function in Scilab but it can be emuled by: or(type(A)==[1 5 8]). |
|
|
|
ispc |
Determine if PC (Windows) version |
MSDOS |
|
|
|
isreal |
Determine if all array elements are real numbers |
isreal |
|
Scilab isreal function can take two values as input. The first one is the same as Matlab one and the second allows to give a tolerance on the absolute value of the imaginary part of first input. So to have the same results in Matlab and in Scilab, second input in Scilab function must be set to 0. |
tf = isreal(1+0i) tf = 1
|
tf = isreal(1+0*%i) tf = %F tf = isreal(1+0*%i,0) tf = %T
|
|
|
|
isscalar(A) |
Determine if input is scalar |
sum(length(A))==1 |
|
|
|
isspace |
Detect elements that are ASCII white spaces |
No equivalent |
|
There is no equivalent function to Matlab isspace function in Scilab. However it can be replaced as shown below. |
tf = isspace(A)
|
If A is a String matrix: tf = asciimat(A)==32 If A is not a String matrix: tf = zeros(A)
|
|
|
|
issparse(S) |
Test if matrix is sparse |
No equivalent |
|
There is no equivalent function for Matlab issparse function in Scilab but it can be emuled by: or(type(S)==[5,6]). |
|
|
|
isstruct(A) |
Determine if input is a structure array |
typeof(A)=="st" |
|
|
|
isstr(A) |
Determine if item is a character array |
type(A)==10 |
|
|
|
isunix |
Determine if Unix version |
~MSDOS |
|
|
|
isvector |
Determine if input is a vector |
No equivalent |
|
There is no Scilab equivalent function for Matlab tf=isvector(A) but there are equivalent instructions: ▹ If A is not a character string: Scilab equivalent is tf = size(A,1)==1 | size(A,2)==1. ▹ If A is a character string: Scilab equivalent is tf = size(asciimat(A),1)==1 | size(asciimat(A),2)==1. |
|
|
|
|
Matlab |
K |
|
|
|
keyboard |
Invoke the keyboard in a file |
pause |
|
|
|
kron(A,B) |
Kronecker tensor product |
A .*. B |
|
|
|
|
Matlab |
L |
|
|
|
length(A) |
Length of vector |
No equivalent |
|
If A is a vector, Scilab equivalent for length(A) is size(A,"*"). If A is a matrix, Scilab equivalent for length(A) is max(size(A)). If A contains character strings, String matrix has to be converted to a "character" string matrix using mstr2sci (Using asciimat to convert will give the same result). Scilab length is different from Matlab length. |
|
|
|
linspace |
Linearly spaced vector |
linspace |
|
When A and/or B is a String in Matlab, linspace(A,B[,n]) returns a String matrix, in Scilab, it can be made with ascii(linspace(ascii(A),ascii(B),n)). |
|
|
|
load |
Load workspace variables from disk |
loadmatfile |
|
Scilab loadmatfile does not handle option -regexp yet. |
|
|
|
log10 |
Common (base 10) logarithm |
log10 |
|
|
|
log2 |
Base 2 logarithm and dissect floating point number |
log2 ↔ frexp |
|
Scilab log2 is equivalent to Matlab log2 for logarithm computation, but for floating point number dissection, Scilab equivalent to Matlab log2 is frexp. |
|
|
|
logical(A) |
Convert numeric values to logical |
No equivalent |
|
If A is not an empty matrix, Scilab equivalent for logical(A) is is not equal to 0 else Scilab equivalent is []. |
|
|
|
log |
Natural logarithm |
log |
|
|
|
lookfor |
Search for specified keyword in all help entries |
apropos |
|
No Scilab equivalent for Matlab -all option. |
|
|
|
lower(str) |
Convert string to lower case |
convstr(str,''u'') |
|
If A is not a character string matrix, Scilab equivalent for B=lower(A) is B=A, else equivalent is B=convstr(A). |
|
|
|
lu |
LU matrix factorization |
lu |
|
There is no Scilab equivalent for Matlab lu when called with 1 or 4 outputs or with 2 inputs. |
|
|
|
|
Matlab |
M |
|
|
|
max |
Maximum |
max |
|
Matlab max function can work with complexes, what Scilab max can not, so a emulation function called mtlb_max has been written. Note that in Scilab, second input parameter can give the dimension to use to find the maximum values or another matrix (maximum of two matrices), in Matlab, dimension parameter is given in a third input parameter (in this case, second parameter must be []). ▹ C=max(A): If A is a matrix, max(A) is equivalent to max(A,[],1) in Matlab whereas in Scilab max(A) gives the maximum value found in A. Matlab max treats the values along the first non-singleton dimension. |
A = [1,2,3;4,5,6] C = max(A) C = [4,5,6] C = max(A,[],1) C = [4,5,6] B=[7,8,9;2,3,4] C = max(A,B) C = [7,8,9;4,5,6]
|
A = [1,2,3;4,5,6] C = max(A) C = 6 C = max(A,''r'') C = [4,5,6] B=[7,8,9;2,3,4] C = max(A,B) C = [7,8,9;4,5,6]
|
|
|
|
min |
Minimum |
min |
|
Matlab min function can work with complexes, what Scilab min can not, so a emulation function called mtlb_min has been written. Note that in Scilab, second input parameter can give the dimension to use to find the minimum values or another matrix (minimum of two matrices), in Matlab, dimension parameter is given in a third input parameter (in this case, second parameter must be []). ▹ C=min(A): If A is a matrix, min(A) is equivalent to min(A,[],1) in Matlab whereas in Scilab min(A) gives the minimum value found in A. Matlab min treats the values along the first non-singleton dimension. |
A = [1,2,3;4,5,6] C = min(A) C = [1,2,3] C = min(A,[],1) C = [1,2,3] B = [7,8,9;2,3,4] C = min(A,B) C = [1,2,3;2,3,4]
|
A = [1,2,3;4,5,6] C = min(A) C = 1 C = min(A,''r'') C = [1,2,3] B = [7,8,9;2,3,4] C = min(A,B) C = [1,2,3;2,3,4]
|
|
|
|
mkdir |
|
mkdir |
|
Scilab mkdir returns 1 or 2 values but Matlab one can return up to three values (third output is a Matlab messageid). |
|
|
|
mod |
Modulus after division |
pmodulo |
|
Scilab pmodulo can work with Complex values what Matlab mod can not. |
|
|
|
more |
Display Command Window output one screenful at a time |
lines |
|
See examples. |
more off more on more(30)
|
lines(0) lines(60) lines(30)
|
|
|
|
|
Matlab |
N |
|
|
|
nargin ↔ nargin('fun') |
Number of function input arguments |
argn(2) ↔ size(getfield(1,macrovar(fun)),"*") |
|
|
|
nargout ↔ nargout('fun') |
Number of function output arguments |
argn(1) ↔ size(getfield(2,macrovar(fun)),"*") |
|
|
|
ndims |
Number of array dimensions |
No equivalent |
|
There is no Scilab equivalent function for ndims(A) but it can be emuled by: size(size(A),"*") |
|
|
|
norm |
Vector and matrix norms |
norm |
|
|
|
num2str |
Number to string conversion |
string ↔ msprintf |
|
▹ num2str(a,precision): There is no Scilab equivalent for this Matlab expression. ▹ num2str(a,format): Scilab equivalent for Matlab num2str(a,format) is msprintf(format,a). |
|
|
|
|
Matlab |
O |
|
|
|
ones |
Create an array of all ones |
ones |
|
Note that in Matlab, A can contain complex values (in these cases, only real part of A is taken in account), what Scilab function do not tolerate. ▹ B=ones(A): If A is a scalar, then Matlab returns a A*A matrix of ones but in Scilab you get a 1, use ones(A,A) to get the same matrix B. If A is a vector, Scilab and Matlab give the same B. Finally, if A is a matrix, in Scilab, B will be a matrix having the same size as A whereas in Matlab, you get an error message. |
B = ones(2) B = [1,1;1,1] B = ones(2,2) B = [1,1;1,1] B = ones([3,3]) B = [1,1,1;1,1,1;1,1,1]
|
B = ones(2) B = 1 B = ones(2,2) B = [1,1;1,1] B = ones([3,3]) B = [1,1]
|
|
|
|
otherwise |
Default part of switch/select statement |
else |
|
|
|
|
Matlab |
P |
|
|
|
pause |
Halt execution temporarily |
xpause ↔ halt |
|
Scilab equivalent for Matlab pause(n) is xpause(1000*n). ▹ pause ↔ halt(): Scilab halt() and Matlab pause are equivalents. ▹ pause on/off: There is no Scilab equivalent for Matlab pause on or pause off |
|
|
|
perms |
Array of all permutations of vector components |
perms |
|
|
|
permute |
Permute the dimensions of an array |
permute |
|
|
|
plot |
Linear 2-D plot |
plot |
|
Scilab plot doesn't accept all the properties of the Matlab plot |
|
|
|
pow2 |
Base 2 power and scale floating-point numbers |
No equivalent |
|
▹ X=pow2(Y): There is not equivalent function for pow2 in Scilab but, when called with one input argument it can be emulated by: 2^ Y ▹ X=pow2(F,E): In this case, Matlab pow2() ignores imaginary part of input arguments. An equivalent expression for this use of pow2 is: F.* 2 .^ E (Note that 2 must be preceeded and followed by a white space). |
|
|
|
primes |
Returns the primes numbers included between 1 and given number |
primes |
|
|
|
prod |
Product of array elements |
prod |
|
▹ M=prod(A): Scilab prod(A) returns the product of all components of A. So, if A is a vector, then Scilab and Matlab work in the same way. If A is a matrix, Scilab prod(A) gives the product of all elements of A but Matlab returns the product of each column. Finally, if A is a multidimensional array, Matlab works on the first non-singleton dimension of A what Scilab does not. So, to be sure to find a Scilab equivalent for Matlab call to prod it is better to precise dimension on which to work. ▹ M=prod(A,dim): In Scilab dim=1 is equivalent to dim=''r'' and dim=2 is equivalent dim=''c''. In Matlab, dim can be greater then the number of dimension of A (in this case, M=A), in Scilab you will get an error message. |
A = [1,2,3;4,5,6] M = prod(A) M = [4,10,18] M = prod(A,1) M = [4,10,18]
|
A = [1,2,3;4,5,6] M = prod(A) M = 720 M = prod(A,''r'') M = [4,10,18]
|
|
|
|
|
Matlab |
Q |
|
|
|
qr |
Orthogonal-triangular decomposition |
qr |
|
When used with two input values and tree output values, Scilab and Matlab qr results can differ. Use mtlb_qr instead. |
|
|
|
quit |
Terminate session |
quit |
|
|
|
|
Matlab |
R |
|
|
|
randn(A) |
Normally distributed random numbers and arrays |
rand(A,''normal'') |
|
▹ B=randn(A) ↔ B=rand(A,``normal''): If A is a scalar, then Matlab returns a A*A random matrix but in Scilab you get a single random value, use rand(A,A,''normal'') to get the same matrix B. Finally, if A is a matrix, in Scilab, B will be a matrix having the same size as A whereas in Matlab, you get an error message.Note that in Matlab, A can contain complex values (in these cases, only real part of A is taken in account), what Scilab function do not tolerate. Particular case: To get the state of the normal generator, in Matlab you have to use s=randn('state') to get 2 current values of the generator, but Scilab equivalent s=rand(``seed'') return only one value.
|
|
|
|
rand(A) |
Uniformly distributed random numbers and arrays |
rand(A[,''uniform'']) |
|
▹ B=rand(A): If A is a scalar, then Matlab returns a A*A random matrix but in Scilab you get a single random value, use rand(A,A) to get the same matrix B. Finally, if A is a matrix, in Scilab, B will be a matrix having the same size as A whereas in Matlab, you get an error message.Note that in Matlab, A can contain complex values (in these cases, only real part of A is taken in account), what Scilab function do not tolerate. Particular case: To get the state of the uniform generator, in Matlab you have to use s=rand('state') to get 35 current values of the generator, but Scilab equivalent s=rand(``seed'') return only one value.
|
|
|
|
rcond |
Matrix reciprocal condition number estimate |
rcond |
|
Scilab and Matlab values differ for empty matrix. |
c = rcond([]) c = Inf
|
c = rcond([]) c = []
|
|
|
|
realmax |
Largest positive floating-point number |
number_properties("huge") |
|
There is no Scilab equivalent for Matlab realmax('single'). |
|
|
|
realmin |
Smallest positive floating-point number |
number_properties("tiny") |
|
There is no Scilab equivalent for Matlab realmin('single'). |
|
|
|
real |
Real part of a complex number |
real |
|
|
|
rem(X,Y) |
Remainder after division |
X-fix(X./Y).*Y |
|
|
|
repmat |
Replicate and tile an array |
No equivalent |
|
There is no Scilab equivalent function for Matlab repmat but it can be replaced by the following expressions (considering m and n being real values): ▹ repmat(A,m) with m a scalar: can be replaced by ones(m,m).*.A if A is of Double type, by ones(m,m).*.bool2s(A) if A is of Boolean type and by asciimat(ones(m,m).*.asciimat(A) if A is of String type ▹ repmat(A,m) with m a vector: can be replaced by ones(m(1),m(2),...).*.A is of Double type, by ones(m(1),m(2),...).*.bool2s(A) if A is of Boolean type and by asciimat(ones(m(1),m(2),...).*.asciimat(A) if A is of String type ▹ repmat(A,m,n): can be replaced by ones(m,n).*.A if A is of Double type, by ones(m,n).*.bool2s(A) if A is of Boolean type and by asciimat(ones(m,n).*.asciimat(A) if A is of String type |
|
|
|
reshape |
Reshape array |
matrix |
|
To get the same result for character string matrices in Scilab than in Matlab, convert Scilab character string matrices using mstr2sci. All unspecified dimensions are represented by a [] input in Matlab while in Scilab they are given by a -1. Matlab reshape suppresses singleton higher dimension, it is not the case for matrix in Scilab... |
|
|
|
return |
Return to the invoking function |
return |
|
|
|
round |
Round to nearest integer |
round |
|
|
|
|
Matlab |
S |
|
|
|
save |
Save workspace variables from disk |
mtlb_save |
|
Scilab mtlb_save does not handle options -v4 -mat and -append yet. |
|
|
|
schur |
Schur decomposition |
schur |
|
|
|
setstr |
Set string flag |
ascii |
|
▹ S = setstr(A) with A a caracter string: In this case, Scilab ascii function convert string to ascii code matrix, but setstr keeps string format. |
|
|
|
sign |
Signum function |
sign |
|
|
|
sinh |
Hyperbolic sine |
sinh |
|
|
|
size |
Array dimension |
size |
|
Due to the fact that strings or not considered in the same way in Matlab and in Scilab, results are not equal for string matrices, convert it using m2scistr to have the same result. ▹ d = size(X,dim): If dim is greater than number of dimensions of X, Matlab returns d=1, but in Scilab, you get an error message. Scilab mtlb_size can work with dim greater than number of dimensions of X. ▹ [d1,...dn] = size(X): If n is greater than number of dimensions of X, all "extra" variables are set to 1 in Matlab but Scilab returns an error message. Scilab mtlb_size returns a Matlab like result in these cases. When n is less than number of dimensions of X, dn contains the product of the sizes of the remaining dimensions in Matlab but in Scilab dn = size(X,n), use mtlb_size for such uses. |
|
|
|
sort |
Sort elements in ascending order |
No equivalent |
|
Scilab sort and Matlab sort are different functions ! For character string inputs, please use better mtlb_sort in Scilab... ▹ B = sort(A): Scilab gsort can be used as an equivalent for Matlb sort giving it the good inputs. If A is a vector, call gsort(A,"g","i"). If A is a matrix then call gsort(A,"r","i"). Note that gsort does not work with multidimensional arrays... ▹ B = sort(A,dim): If in Matlab, dim is 1 (respectively 2) then replace it by "r" (respectively "c") in Scilab when calling gsort(A,dim,"i"). Note that gsort does not work with multidimensional arrays... |
|
|
|
sparse |
Create sparse matrix |
sparse |
|
Matlab and Scilab equivalents: ▹ sparse(A) ↔ sparse(A):
▹ sparse(m,n) ↔ sparse([],[],[m,n]):
▹ sparse(i,j,s) ↔ sparse([i,j],s): This equivalence is true considering i, j and s have the same length and that i and j are column vectors. ▹ sparse(i,j,s,m,n) ↔ sparse([i,j],s,[m,n]): This equivalence is true considering i, j and s have the same length and that i and j are column vectors. ▹ sparse(i,j,s,m,n,nzmax): There is no Scilab equivalent for this use of Matlab sparse. |
|
|
|
strcmpi(str1,str2) |
Compare strings ignoring case |
convstr(str1)==convstr(str2) |
|
Note that strcmpi can be use with not string inputs, in this case Matlab returns 0. Scilab == will in this case return %T if both inputs are equal... |
|
|
|
strcmp(str1,str2) |
Compare strings |
str1==str2 |
|
Note that strcmp can be use with not string inputs, in this case Matlab returns 0. Scilab == will in this case return %T if both inputs are equal... |
|
|
|
strfind |
Find one string within another |
strindex |
|
Note that strfind can be use with not string inputs, in this case Matlab returns 1 if inputs are equal and 0 else but strindex can not do such comparison... |
|
|
|
strrep |
String search and replace |
strsubst |
|
Note that Matlab strrep can be use with not string inputs, what Scilab strsubst can not. In this case use mtlb_strrep instead. |
|
|
|
struct |
Create struct array |
struct |
|
|
|
sum |
Sum of array elements |
sum |
|
▹ M=sum(A): Scilab sum(A) returns the sum of all components of A. So, if A is a vector, then Scilab and Matlab work in the same way. If A is a matrix, Scilab sum(A) gives the sum of all elements of A but Matlab returns the sum of each column. Finally, if A is a multidimensional array, Matlab works on the first non-singleton dimension of A what Scilab does not. So, to be sure to find a Scilab equivalent for Matlab call to sum it is better to precise dimension on which to work. ▹ M=sum(A,dim): In Scilab dim=1 is equivalent to dim=''r'' and dim=2 is equivalent dim=''c''. In Matlab, dim can be greater then the number of dimension of A (in this case, M=A), in Scilab you will get an error message. |
A = [1,2,3;4,5,6] M = sum(A) M = [5,7,9] M = sum(A,1) M = [5,7,9]
|
A = [1,2,3;4,5,6] M = sum(A) M = 21 M = sum(A,''r'') M = [5,7,9]
|
|
|
|
surf |
3-D surface plot |
surf |
|
Scilab surf doesn't accept all the properties of the Matlab surf |
|
|
|
svd |
Singular value decomposition |
svd |
|
|
|
switch |
Switch among several cases based on expression |
select |
|
|
|
|
Matlab |
T |
|
|
|
tanh |
Hyperbolic tangent |
tanh |
|
|
|
tic |
Starts a stopwatch timer |
tic() |
|
In Scilab, tic can be called as a command when output value is just displayed. |
|
|
|
title |
Display a title on a graphic window |
title |
|
|
|
toc |
Read the stopwatch timer |
toc() |
|
In Scilab, toc can be called as a command when output value is just displayed. |
|
|
|
toeplitz |
Toeplitz matrix |
toeplitz |
|
toeplitz can be used with empty matrices in Scilab but not in Matlab. ▹ T=toeplitz(c): If c is complex, use mtlb_toeplitz in Scilab to have the same result than Matlab.Else if c is not a scalar or a vector, use mtlb_toeplitz in Scilab to have the same result than Matlab. ▹ T=toeplitz(c,r): If c and r are not scalars or vectors or if c(1,1)<>r(1,1), use: mtlb_toeplitz in Scilab to have the same result than Matlab. |
|
|
|
tril |
Lower triangular part of a matrix |
tril |
|
In L=tril(X) and L=tril(X,k), Scilab function gives different results from Matlab one if X is a String matrix. In this case use mtlb_tril instead. Note that k can be complex in Matlab, in this case, only real part of k is taken in account, Scilab gives an error message for a such use. |
|
|
|
triu |
Upper triangular part of a matrix |
triu |
|
In U=triu(X) and U=triu(X,k), Scilab function gives different results from Matlab one if X is a String matrix. In this case use mtlb_triu instead. Note that k can be complex in Matlab, in this case, only real part of k is taken in account, Scilab gives an error message for a such use. |
|
|
|
true |
True array |
No equivalent |
|
To get the same result in Scilab, use: ones(...)==1. See ones. |
|
|
|
type |
List file |
No equivalent |
|
Scilab mtlb_type is a partial emulation of Matlab type function. Scilab type function does not match with Matlab type ! |
|
|
|
|
Matlab |
U |
|
|
|
uigetdir |
Standard dialog box for selecting a directory |
tk_getdir |
|
|
|
uint16 |
Convert to 16-bit unsigned integer |
uint16 |
|
For infinite values, Scilab and Matlab uint16 return different values. |
A = uint16(inf) A = 65535
|
A = uint16(%inf) A = 0
|
|
|
|
uint32 |
Convert to 32-bit unsigned integer |
uint32 |
|
For infinite values, Scilab and Matlab uint32 return different values. |
A = uint32(inf) A = 4294967295
|
A = uint32(%inf) A = 0
|
|
|
|
uint8 |
Convert to 8-bit unsigned integer |
uint8 |
|
For infinite values, Scilab and Matlab uint8 return different values. |
A = uint8(inf) A = 255
|
A = uint8(%inf) A = 0
|
|
|
|
unix |
Execute a UNIX command and return result |
unix_g |
|
Output values order is inversed in Scilab and in Matlab. In Scilab use disp to emulate Matlab -echo option. |
[status,result] = unix(...)
|
[result,status] = unix_g(...)
|
|
|
|
upper(str) |
Convert string to upper case |
convstr(str,''u'') |
|
If A is not a character string matrix, Scilab equivalent for B=upper(A) is B=A, else equivalent is B=convstr(A,''u''). |
|
|
|
|
Matlab |
V |
|
|
|
varargin |
Pass variable numbers of arguments |
varargin |
|
In Matlab varargin is a cell and in Scilab it is a list. |
|
|
|
varargout |
Return variable numbers of arguments |
varargout |
|
In Matlab varargout is a cell and in Scilab it is a list. |
|
|
|
vertcat |
Vertical concatenation |
No equivalent |
|
Scilab equivalent for Matlab vertcat(A1,A2,...,An) is [A1;A2;...;An]. |
|
|
|
|
Matlab |
W |
|
|
|
waitforbuttonpress |
Wait for key or mouse button press |
No equivalent |
|
There is no equivalent function for Matlab w=waitforbuttonpress in Scilab however it can be replaced by: [%v0,%v1,%v2,%v3,%v4] = xclick();w = bool2s(%v0>64); |
|
|
|
warning |
Display warning messages |
warning |
|
Scilab warning function can only take one character string as input but Matlab function can take more than one character string as input and also numerical values... |
|
|
|
while |
Repeat statements an indefinite number of times |
while |
|
|
|
whos |
List variables in the workspace |
whos |
|
Scilab whos is an equivalent for Matlab whos just when called as follows: whos or whos("global") |
|
|
|
who |
List variables in the workspace |
who |
|
Scilab who is an equivalent for Matlab who just when called as follows: who or who("global") |
|
|
|
winqueryreg |
Get item from Microsoft Windows registry |
winqueryreg |
|
Scilab function returns a matrix of strings or a int32 value but Matlab function returns a Cell of strings or a int32 value. |
|
|
|
|
Matlab |
X |
|
|
|
xlabel |
Display a string along the x axis |
xlabel |
|
|
|
|
Matlab |
Y |
|
|
|
ylabel |
Display a string along the y axis |
ylabel |
|
|
|
|
Matlab |
Z |
|
|
|
zeros |
Create an array of all zeros |
zeros |
|
▹ B=zeros(A): If A is a scalar, then Matlab returns a A*A matrix of zeros but in Scilab you get a 1, use zeros(A,A) to get the same matrix B. If A is a row vector, Scilab and Matlab give the same B. Finally, if A is a matrix, in Scilab, B will be a matrix having the same size as A whereas in Matlab, you get an error message.Note that in Matlab, A can contain complex values (in these cases, only real part of A is taken in account), what Scilab function do not tolerate.
|
B = zeros(2) B = [0,;0,0] B = zeros(2,2) B = [0,0;0,0] B = zeros([3,3]) B = [0,0,0;0,0,0;0,0,0]
|
B = zeros(2) B = 0 B = zeros(2,2) B = [0,0;0,0] B = zeros([3,3]) B = [0,0]
|
|
|
|
zlabel |
Display a string along the z axis |
zlabel |
|
|
|
|
Matlab |
Operators |
|
|
|
: |
Colon |
: |
|
▹ Using colon with empty matrices: In Matlab if almost one operand is an empty matrix, then result is an empty matrix what gives an error message in Scilab. ▹ Using colon with NaNs and Infs: In Matlab if almost one operand is an empty matrix, then result is a NaN what make Scilab returning an error. |
|
|
|
+ |
Plus |
+ |
|
▹ Character strings addition: In Scilab, string addition is the same as string concatenation, what is done in Matlab by strcat function. In Matlab, string addition is the equivalent of the addition of corresponding ASCII codes. ▹ Empty matrix and addition: In Matlab, addition can only be made if the operands have the same size unless one is a scalar. For exemple, empty matrices can only be added to another empty matrix or a scalar. Note that when you add a scalar and an empty matrix, Matlab result is always an empty matrix while in Scilab, result is equal to the scalar. ▹ Unary plus: In Matlab, unary plus exists, but in Scilab it is automatically deleted when compiling so we can consider that Scilab unary plus does not exist. |
str = 'str1'+'str2' str = [230,232,228,99] str = strcat('str1','str2') str = 'str1str2' A = 1 + [] A = []
|
str = 'str1'+'str2' str = 'str1str2' str = strcat(['str1','str2']) str = 'str1str2' A = 1 + [] A = 1
|
|
|
|
- |
Minus |
- |
|
▹ Empty matrix and substraction: In Matlab, substraction can only be made if the operands have the same size unless one is a scalar. For exemple, empty matrices can only be substracted to another empty matrix or a scalar. Note that when you substract an empty matrix to a scalar and inversely, Matlab result is always an empty matrix while in Scilab, result is equal to the scalar. |
A = 1 - [] A = []
|
A = 1 - [] A = 1
|
|
|
|
\ |
Left division |
\ |
|
Note that Matlab left division gives strange results when one operand is a character string matrix and not the other one... |
|
|
|
.* |
Elementwise mutiplication |
.* |
|
WARNING: Expressions like X.*.23 are interpreted in Matlab as X elementwisely multiplied by 0.23 while Scilab computes the Kronecker product of X and 23, to have the same result, insert a blank between * and .23 |
|
|
|
./ |
Elementwise right division |
./ |
|
WARNING: Expressions like X./.23 are interpreted in Matlab as the elementwise right division of X by 0.23 while Scilab computes the Kronecker right division of X and 23, to have the same result, insert a blank between / and .23 |
|
|
|
.\ |
Elementwise left division |
.\ |
|
WARNING: Expressions like X.\.23 are interpreted in Matlab as the elementwise division of 0.23 by X while Scilab computes the Kronecker left division of X and 23, to have the same result, inser a blank between \ and .23 |
|
|
|
.' |
Elementwise transpose |
.' |
|
▹ Character string elementwise transpose: In Scilab, the result of a character string elementwise transpose is the string itself; but in Matlab, elementwise transpose of a character string gives a column vector of characters. To have the same result in Scilab, use: mtlb_0. |
s = ('str1')' s = ['s';'t';'r';'1']
|
s = ('str1')' s = 'str1' s = mtlb_0('str1') s = ['s';'t';'r';'1']
|
|
|
|
.^ |
Elementwise exponent |
.^ |
|
Note that Matlab seems to have a bug when exposant is a character... WARNING: Expressions like X.^.23 are interpreted in Matlab as X to the power of 0.23 while Scilab executes X elementwisely powered to 23, to have the same result, inser a blank between ^ and .23 |
|
|
|
' |
Transpose |
' |
|
▹ Character string transpose: In Scilab, the result of a character string transpose is the string itself; but in Matlab, transpose of a character string gives a column vector of characters. To have the same result in Scilab, use: mtlb_t. |
s = ('str1')' s = ['s';'t';'r';'1']
|
s = ('str1')' s = 'str1' s = mtlb_t('str1') s = ['s';'t';'r';'1']
|
|
|
|
& |
Logical AND |
& |
|
Due to the fact that strings or not considered in the same way in Matlab and in Scilab, results are not equal for string matrices, convert it to ascii code matrices using m2scistr to have the same result. Scilab function has a bug! |
|
|
|
| |
Logical OR |
| |
|
Due to the fact that strings or not considered in the same way in Matlab and in Scilab, results are not equal for string matrices, convert it to ASCII code matrices using m2scistr to have the same result. Scilab function has a bug! |
|
|
|
> |
Greater than |
> |
|
When both operands are empty matrices, Matlab result is an empty matrix while in Scilab you get an error. In Scilab this operator does not work with complex values while in Matlab it considers Real part of them for comparison. |
|
|
|
>= |
Greater or equal to |
>= |
|
When both operands are empty matrices, Matlab result is an empty matrix while in Scilab you get an error. In Scilab this operator does not work with complex values while in Matlab it considers Real part of them for comparison. |
|
|
|
< |
Smaller than |
< |
|
When both operands are empty matrices, Matlab result is an empty matrix while in Scilab you get an error. In Scilab this operator does not work with complex values while in Matlab it considers Real part of them for comparison. |
|
|
|
<= |
Smaller or equal to |
<= |
|
When both operands are empty matrices, Matlab result is an empty matrix while in Scilab you get an error. In Scilab this operator does not work with complex values while in Matlab it considers Real part of them for comparison. |
|
|
|
^ |
Exponent |
^ |
|
Note that Matlab seems to have a bug for X^(Y) when X is a character and that in Scilab operations such as X^(Y) with X a scalar and Y a matrix is equivalent to X.^(Y) (Will change in next Scilab versions...). |
|
|
|
~ |
Negation |
~ |
|
Due to the fact that strings or not considered in the same way in Matlab and in Scilab, results are not equal for string matrices, convert it to ascii code matrices using m2scistr to have the same result. |
|
|
|
|
Matlab |
Variables |
|
|
|
ans |
The most recent answer |
ans |
|
|
|
eps |
Floating-point relative accuracy |
%eps |
|
Only Matlab allows to change the value of this variable and clear eps allows to set the value of eps to its initial value. |
|
|
|
i |
Imaginary unit |
%i |
|
Only Matlab allows to change the value of this variable. |
|
|
|
j |
Imaginary unit |
%i |
|
Only Matlab allows to change the value of this variable. |
|
|
|
pi |
Ratio of a circle's circumference to its diameter |
%pi |
|
Only Matlab allows to change the value of this variable. |
|