Skip to content

Instantly share code, notes, and snippets.

@TejasBhovad
Created August 28, 2022 05:54
Show Gist options
  • Save TejasBhovad/60bb1e8029f056383de3ac615e235c54 to your computer and use it in GitHub Desktop.
Save TejasBhovad/60bb1e8029f056383de3ac615e235c54 to your computer and use it in GitHub Desktop.
unofficial and easy to understand documentation for Scilab for academic purposes (WIP)

Scilab

New-Project.png

Scilab Documentation made for academic purposes

Basics

Arithmetic operations

eg: 8+3

Screenshot-2022-08-28-at-11-02-41-AM.png

All operators that can be used

+        Addition
-        subtraction
*        multiplication
/        right division
\        left division 
^ or **  power
'        transpose
=        asignment operator
==       compare two values

Creating and using variables

declaring a variable in scilab is as simple as a=8

Screenshot-2022-08-28-at-11-03-45-AM.png

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

comments are group of words that don't affect the execution of a program // this is a comment In scilab // starts a comment

Mathematical functions

Screenshot-2022-08-28-at-11-08-30-AM.png

Booleans & Logical statements

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

Complex Numbers

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

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

Definitions

Arrays are group of variables of same data-type e.g. a=[1,2,3] these are also called vectors in scilab

Matrices

row matrix

there are two ways to define a row matrix in scilab a = [1 2 3] or a = [1,2,3]

Screenshot-2022-08-28-at-11-11-21-AM.png

Column matrix

a = [1;2;3]

Screenshot-2022-08-28-at-11-14-16-AM.png

m x n matrix

every time a new column is to be added an semicolon is used e.g. a = [1,2,3;4,5,6]

Screenshot-2022-08-28-at-11-15-06-AM.png

empty matrix

matrix with nothing inside a = []

commands related to creating matrices

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

functions related to matrices

  • 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 matrix
  • resize_matrix creates a new matrix with different size

accessing part of a matrix

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment