Scilab

From Script | Spoken-Tutorial
Jump to: navigation, search

Template:Spoken Tutorial Banner

Scilab (http://scilab.org, http://scilab.in, http://scilab.cn) is an open source scientific software package for numerical computations. It has an extremely reliable and efficiently coded numerical library. It is also a high productivity tool: Through its interpreted language, one can quickly develop the code required to solve problems. Typically, if it takes ten lines of C code for some calculation, Scilab would require only one for the same purpose.

Scilab runs on all popular operating systems. Since 1994, it has been distributed freely along with the source code via the Internet. It is useful for students at school, college and roupas da moda research level. It is also useful for researchers and professionals.

IIT Bombay is leading the effort to popularise Scilab in India. This is part of the Free and Open source Software for Science and Engineering Education (FOSSEE) project, supported by the National Mission on Education through ICT of MHRD (http://spoken-tutorial.org/NMEICT-Intro).

IIT Bombay is using Spoken Tutorials (http://spoken-tutorial.org) to create learning material for FOSS. This is the main page for the organisation of the scripts required for Scilab spoken tutorials. We invite the Scilab user community to participate in this activity.

Note: Each numbered topic corresponds to a single spoken tutorial. Each bulleted point corresponds to a command or topic that must be covered organic nuts in the given spoken tutorial.


General Information

This topic will include all functionality in Scilab that iphone photography is not domain specific- functionality that is required across several domains.

Why Scilab

Basic Level Introduction to Scilab

This level will include a set of tutorials that are required to be known in order to qualify as "Scilab Literate". The tutorials here will teach programming weight loss pills fundamentals and the most commonly used Scilab functionality- Matrix operations and Plotting.

  1. Installing
    • Show where to download from and how to decide which version to choose
    • Windows installation
    • Linux installation (using package manager- show only Debian/Ubuntu as example (sudo apt-get install scilab) as well as generic binary)
    • Mac
    • Compilation from source can come as a part of a more advanced tutorial
  2. Getting Started: Basic Housekeeping
    • Expressions: Show mathematical expressions with numbers
    • Variables
    • Diary command
    • Define symbolic constants.
    • Basic functions
    • suppressing output(;)
    • help,clc
  3. Matrix Operations
  4. Vector Operations
    • Define vector
  5. Matrix Operations
    • Square matrices
    • det(Q), diag(Q)
    • Matrix generation: zeros(3,4), ones(2,5), eye(4,4), diag([1 2 3]), rand(2,3).
    • Ranges: 1:4, 2:2:8, linspace(1, 9, 5) (linspace is to be explained in Plotting 2D graphs tutorial)
    • Elementary row operations
    • Solving equations
  6. Conditional Branching
    • Explain booleans
    • First explain 'if' and 'then' with the example
    • Now explain the use of the 'else' keyword
    • Now explain the use of the 'elseif' keyword
    • Say that if there are several branches, it may be clearer to use the 'select' keyword.
    • Give example for select
    • Branching can be based on satisfaction of combination of multiple conditions as well
  7. Iteration
    • Explain syntax of 'for' statement- tell that the variable iterates over a list/vector/matrix
    • Break condition.
    • continue condition.
    • while condition.
    • break, continue condition with example in while loop.
  8. Plotting 2D graphs
    • About linspace: linspace is a linearly spaced vector.
    • Plot a simple graph: x=linspace(12,34,10), y=linspace(-.1,2,10), plot(x,y)
    • plot2d
    • Using clf() clear the graphic window.
    • Configure the title for the plot
    • Configure a legend
    • Divide a graphic window into a matrix of sub-windows using subplot(mnp)
  9. Scripts and Functions
    • Explain that one often repeats a set of commands- in which case it is helpful to save that set of commands for future or repeated use. The commands can be saved as scripts or functions.
    • Change directory to the desktop. Open the scilab editor and type the commands (each on a new line)
    • Save the above file to the desktop. Then open the same file using a regular text editor such as notepad to show that it is indeed a text file. Now load the file into scilab using the scilab editor's execute menu option.
    • Change the value of a to 5 in the editor, save and close it. Now execute the script directly from the scilab interpreter using exec.
    • Functions: Show the syntax of functions, explain the function keyword, input arguments and the structure of output arguments when there is more than one argument.
    • Show the following function in the editor: .
    • Inline functions.
    • .sce versus .sci: These are just conventions.
  10. Input and Output
    • Console input and output.
    • Reading and writing in files: Do a = rand(20, 1)
      • Text files:
        • Output- write()
        • Input- read()
      • Binary files
        • Output- save()
        • Input- load()

Advanced Level Scilab

  1. File Handling- Scilab File handling
    • Writing to a file using write()
    • Reading from a file using read()
    • Opening an existing file using mopen()
    • Closing an already opened file using mclose()
  2. File Handling- User Defined Input and Output in Scilab
    • Input Function
    • mprintf()
    • save() and load()
    • Used to quit scilab midway through calculation and continue at later stage
  3. Numerical methods- Integration
  4. Numerical methods- Solving Non- linear Equations
  5. Numerical methods- Gauss Elimination Method and Gauss Jordan Method
  6. Numerical methods- Iterative Methods
  7. Numerical methods- Interpolation
  8. Numerical methods- ODE- Euler methods
  9. Numerical methods- ODE- Applications
  10. Optimization Using Karmarkar Functions
    • About Optimization
    • Use of Scilab function Karmarkar in Optimization
  11. Optimization of Non-linear Functions
  12. Digital Signal Processing
  13. Filter Design- Windowing Techniques
  14. Filter Design- Window Based FIR Filter
  15. Filter Design- IIR Digital Filter
  16. Filter Design- Applying Digital Filter
  17. Control systems
  18. Discrete systems
  19. Calling User Defined Functions in XCOS
    • Write a squaring function
    • Use of scifunc block in XCOS
    • Use of MUX block
    • Call functions having multiple inputs and output

tutorials on Control Systems

Representing control systems and their properties

  1. First order systems (1)
    • Defining a system
    • Simulating the system
      • Step test
      • Sine test (at two different frequencies)
    • Root locus
    • Bode plot
    • Nyquist plot (1)
  2. Second order systems (2)
    • Underdamped system
      • Defining the system
      • Roots of denominator
    • Step test
  3. Other system representations (3)
    • Discrete time systems (3)
      • Defining a system
      • Simulating the system (step test)
      • Bode plot
      • Root locus
    • Discretizing continuous time systems (3)
  4. State space representation (4)
    • Defining the system and initial state
    • Simulating the system
    • Plotting output state and internal state
    • Root locus
    • Conversion to transfer function
      • Compare roots of denominator of answer with eigenvalues of A matrix.
  5. Multiple subsystems (5)
  6. Modeling a system (6)
    • Obtain ODE representation of a system
    • Laplace transform representation of the system
    • Comparison with a second order model (obtain natural freq. and damping factor)
  7. Analyzing the system (7)
    • Open loop step response
    • Step response with unity feedback
    • Steady state error: open loop system as well as unity feedback system
    • Root locus and finding the gain from a point on the root locus.
  8. Controlling the system (8)
    • Proportional control
    • Deciding the parameters to be achieved (overshoot/rise time, etc)
    • Determining corresponding system parameters (natural freq., damping factor)
    • Obtaining location of corresponding point on root locus and gain there
    • Building and simulating the proportional controller
  9. Other Controllers (9)
    • PI Control
    • PD Control
    • PID Control
    • Comparing all controllers

Robotics

  1. rtss Toolbox

Signal Processing

  1. Signal Processing Basics
  2. Audio processing
  3. Image Processing
  4. Fourier Transforms

Other Topics

Ordinary Differential Equations

(Spoken Tutorial-1 Scripts)
  1. Introduction to ODEs
    • Use <math>\frac{dx}{dt} = sin(2t)</math> as the first order example and solve using ode.

      • System:
    <source lang="scilab" line start="1"> function dx = f(t, x) dx = sin(2∗t) ; endfunction </source>
    • 2nd order differntial equation, Lotka Volterra equation example,
    • Using champ to show arrows.
    • With input (nonlinear input/state system). van der Pol oscillator?
    • 3rd order, show example and plot.
    • One example for discrete time system (difference equation) (of order 2)
    • Show points evolving in plane.
    • Linear system: syslin
    • Solution:
    <source lang="scilab" line start="1"> t0 = 0 x0 = −0.5 t = 0:0.1:5; x = ode( x0 , t0 , t , f ) ; plot2d(t , x) </source>
  2. Using ODEOPTIONS
  3. Implicit Differential Equations


Boundary Value Problems

Difference Equations

Differential Algebraic Equations

Partial Differential Equations

Linear Algebra

Revise linsolve.

spec, det, generalized eigenvalue (spec)

inv and pinv (pseudo inverse), svd, companion-form

trace, sum of eigenvalues almost same as trace (similarly determinant and product of eigenvalues)

Optimization

Probability and Statistics

Scilab Toolboxes

Symbolic toolbox Scripts
Scilab Wavelet toolbox Scripts

Special Functions

  1. Bessel functions
  2. Beta function
    • Definition
    • beta(m,n)=beta(n,m)
    • beta(m,n)=gamma(m)*gamma(n)/gamma(m+n)
  3. Gamma function
    • Definition
    • gamma(1), gamma(0)
    • gamma(n+1)=n!
    • gamma(11/2), gamma(1/2)
  4. Error function
  5. Legendre functions

Least squares fit, splines

Polynomial interpolation

Close relation between interpolation and van der Monde matrix

Subset of columns of van der Monde matrix will correspond to lower degree fit.

Solvability of over-determined equations perhaps not possible.

Pseude inverse corresponds to "least squares fit" of specified degree.

Data Handling

  1. Databases
  2. XMLLab

==Web Interface for Scilab (W3 Scilab)==

Contributors and Content Editors

Lavitha Pereira, Minal, Nancyvarkey, PoojaMoolya, Pratik kamble