eg: 8+3
All operators that can be used
+ Addition
- subtraction
* multiplication
/ right division
\ left division
^ or ** power
' transpose
= asignment operator
== compare two values
declaring a variable in scilab is as simple as a=8
if you don't want it to output value of a then write a=8;
instead
image of a=8;
Adding two variables
a=1;
b=5;
a+b
in this case, a temporary ans
variable is created which holds the value of a+b
variable names in scilab are case sensitive which means A ≠ a
Some pre-defined variables
%i imaginary number
%e euler's constant
%pi π constant
comments are group of words that don't affect the execution of a program
// this is a comment
In scilab //
starts a comment
Booleans are data types which only returns true or false
%f or %F - False
%t or %T - True
List of all Logical Statements
a&b logical and true if both statements are fulfilled
a|b logical or true if either of two statements are fulfilled
~a logical not negates a given statement
a~=b not equal to true if two expressions are different
a<b less than true if a is less than b
a<=b less than equal true if a is less than or equal to b
a>b more than true if a is more than b
a>=b more than equal true if a is more than or equal to b
real(x) find real part of x
imag(x) find imaginary part of x
imult(x) multiplication by i, the imaginary unit
isreal(x) returns true if the variable has no complex entry
e.g. of a complex number: 1+%i
Strings are groups of words
e.g. a = "String"
Two string can be "added" [process of concatenation]
e.g.
a="foot";
b="ball"
a+b
football
Arrays are group of variables of same data-type
e.g. a=[1,2,3]
these are also called vectors in scilab
there are two ways to define a row matrix in scilab
a = [1 2 3] or a = [1,2,3]
a = [1;2;3]
every time a new column is to be added an semicolon is used
e.g. a = [1,2,3;4,5,6]
matrix with nothing inside
a = []
eye() identity matrix
linspace linearly spaced vector
ones() matrix where all elements are 1
zeros() matrix where all elements are 0
testmatrix generate some particular matrices
grand random number
rand random number
size(A)
finds the no. of rows and columns of matrix A e.g.[nr,nc] = size(A)
where nr is no. of row & nc is no. of columns
size(A, sel)
sel = "1" or "r" no. of rows
sel = "2" or "c" no. of column
sel = * total no. of elements
matrix
reshapes a matrix to a different size matrixresize_matrix
creates a new matrix with different size
A(:,:) whole matrix
A(i:j,k) elements at rows from i to k, at column k
A(i,j:k) elements at row i, at columns from j to k
A(i,:) the row i
A(:,j) the column j
Disclaimer: This Document isn't affiliated with 'scilab' or 'ESI Group' and is meant for educational purposes