Introduction to Scilab

68
Introduction to Scilab Use Scilab, not Matlab Kannan M. Moudgalya IIT Bombay [email protected] Coordinator Training 10,000 Teacher Training Programme IIT Bombay June 2012 Kannan Moudgalya Use Scilab, not Matlab 1/68

Transcript of Introduction to Scilab

Page 1: Introduction to Scilab

Introduction to ScilabUse Scilab, not Matlab

Kannan M. MoudgalyaIIT Bombay

[email protected]

Coordinator Training10,000 Teacher Training Programme

IIT BombayJune 2012

Kannan Moudgalya Use Scilab, not Matlab 1/68

Page 2: Introduction to Scilab

Outline

I Open Source Software

I History of Scilab

I Usage of Scilab

I Comparing other open source softwaresystems

Kannan Moudgalya Use Scilab, not Matlab 2/68

Page 3: Introduction to Scilab

FOSS: Free and Open Source Software

I Commercial software is expensiveI Heavy penalties if unauthorised software

is used by industryI Stories from Italy, HLL, WIPRO

I Our SME’s don’t use ANY software:I commercial software is expensiveI they are not aware of open source software

I Makes small companies uncompetitive

I There is no alternative to open sourcesoftware

Kannan Moudgalya Use Scilab, not Matlab 3/68

Page 4: Introduction to Scilab

Scilab

I A good substitute for Matlab

I About 95% compatibility

Kannan Moudgalya Use Scilab, not Matlab 4/68

Page 5: Introduction to Scilab

What is Scilab?

I Free and open source

I Easy to useI Excellent computational environment:

I LINPACK, EISPACK, LAPACK: same asMatlab

I Other software not available for Matlab:Dassl, ODEPACK, etc.

Kannan Moudgalya Use Scilab, not Matlab 5/68

Page 6: Introduction to Scilab

Scilab is created for mathematicians

I Matrices and vectors can be createdeasily - no typing, storage allocation, etc.

I Matrix-vector product,scalar-vector/matrix products are writtenwithout any fuss - like themathematicians do

I Belongs to Matlab family - originallycreated by Prof. Cleve Moler, who hadworked on Linpack and Eispack projects

Kannan Moudgalya Use Scilab, not Matlab 6/68

Page 7: Introduction to Scilab

History of Scilab

I Prof. Cleve Moler created Matlabthrough NSF funding

I As Government funded, source code hadto be made available

I Many companies started using this ideaI Matrixx

I CTRL-CI MatlabI Scilab

I Used extensively for linear algebra,simulation, control system design

I Scilab - a recent story

Kannan Moudgalya Use Scilab, not Matlab 7/68

Page 8: Introduction to Scilab

Scilab - other features

I Can call programs written in Fortran, C

I Good graphics capability

I Large installed base

I A lot of algorithms implemented ininterpreted language as well

I Free

I Check out www.scilab.org orwww.scilab.in

Kannan Moudgalya Use Scilab, not Matlab 8/68

Page 9: Introduction to Scilab

How reliable is Scilab?

I CNES - France’s ISRO

I CNES Arianne rockets

I CNES relies on Scilab for many criticalcalculations:trajectory, flight dynamics, orbit

Kannan Moudgalya Use Scilab, not Matlab 9/68

Page 10: Introduction to Scilab

CNES Talk

I Use of Scilab for Space Mission Analysisand Flight Dynamics Activities

I by Thierry Martin

I Senior Manager, CNES

Kannan Moudgalya Use Scilab, not Matlab 10/68

Page 11: Introduction to Scilab

Purchase of Matlab at IIT Bombay - AStory

Kannan Moudgalya Use Scilab, not Matlab 11/68

Page 12: Introduction to Scilab

Usage of Scilab

Kannan Moudgalya Use Scilab, not Matlab 12/68

Page 13: Introduction to Scilab

Simple Arithmetic - 1

4+6+12

ans =

22.

a = 4, b = 6; c = 12

a =

4.

c =

12.

a+b+c

ans =

22.Kannan Moudgalya Use Scilab, not Matlab 13/68

Page 14: Introduction to Scilab

Useful Commands

I demosI Gives demos on several different things

I aproposI Helps locate commands associated with a

word

I helpI functional invocation with no arguments

I Helps draw plots

I diaryI Stores all commands and resulting outputs

Kannan Moudgalya Use Scilab, not Matlab 14/68

Page 15: Introduction to Scilab

Simple Arithmetic & Display

a = 4; b = 6; c = 12;

d = a+b+c

d =

22.

d = a+b+c;

d

d =

22.

Kannan Moudgalya Use Scilab, not Matlab 15/68

Page 16: Introduction to Scilab

Simple Arithmetic

x = sqrt(2)/2, y = asin(x)

x =

0.7071068

y =

0.7853982

y_deg = y * 180 /%pi

y_deg =

45.Kannan Moudgalya Use Scilab, not Matlab 16/68

Page 17: Introduction to Scilab

Vector Operation - 2 I

-->a = 1:5, b = 1:2:9

a =

! 1. 2. 3. 4. 5. !

b =

! 1. 3. 5. 7. 9. !

-->c = [b a]

c =

! 1. 3. 5. 7. 9. 1. 2. 3. 4. 5. !Kannan Moudgalya Use Scilab, not Matlab 17/68

Page 18: Introduction to Scilab

Vector Operation - 2 II

-->d = [b(1:2:5) 1 0 1]

d =

! 1. 5. 9. 1. 0. 1. !

Kannan Moudgalya Use Scilab, not Matlab 18/68

Page 19: Introduction to Scilab

Vector Operation - 3 I

-->a, b

a =

! 1. 2. 3. 4. 5. !

b =

! 1. 3. 5. 7. 9. !

-->a - 2

Kannan Moudgalya Use Scilab, not Matlab 19/68

Page 20: Introduction to Scilab

Vector Operation - 3 II

ans =

! - 1. 0. 1. 2. 3. !

-->2*a-b

ans =

! 1. 1. 1. 1. 1. !

Kannan Moudgalya Use Scilab, not Matlab 20/68

Page 21: Introduction to Scilab

Logical Operators

== equal to< less than> greater than<= less than or equal to>= greater than or equal to<> or ∼= not equal to

Kannan Moudgalya Use Scilab, not Matlab 21/68

Page 22: Introduction to Scilab

Vector Operations Using LogicalOperators I

-->A = 1:9, B = 9-A

A =

! 1. 2. 3. 4. 5. 6. 7. 8. 9. !

B =

! 8. 7. 6. 5. 4. 3. 2. 1. 0. !

-->tf = A==B

Kannan Moudgalya Use Scilab, not Matlab 22/68

Page 23: Introduction to Scilab

Vector Operations Using LogicalOperators II

tf =

! F F F F F F F F F !

-->tf = A>B

tf =

! F F F F T T T T T !

Kannan Moudgalya Use Scilab, not Matlab 23/68

Page 24: Introduction to Scilab

Transpose I

-->c = [1;2;3]

c =

! 1. !

! 2. !

! 3. !

-->a=1:3

Kannan Moudgalya Use Scilab, not Matlab 24/68

Page 25: Introduction to Scilab

Transpose II

a =

! 1. 2. 3. !

-->b = a’

b =

! 1. !

! 2. !

! 3. !

Kannan Moudgalya Use Scilab, not Matlab 25/68

Page 26: Introduction to Scilab

Submatrix I

-->A=[1 2 3;4 5 6;7 8 9]

A =

! 1. 2. 3. !

! 4. 5. 6. !

! 7. 8. 9. !

-->A(3,3)=0

Kannan Moudgalya Use Scilab, not Matlab 26/68

Page 27: Introduction to Scilab

Submatrix II

A =

! 1. 2. 3. !

! 4. 5. 6. !

! 7. 8. 0. !

Kannan Moudgalya Use Scilab, not Matlab 27/68

Page 28: Introduction to Scilab

Submatrix I

A

A =

! 1. 2. 3. !

! 4. 5. 6. !

! 7. 8. 0. !

-->B=A(3:-1:1,1:3)

Kannan Moudgalya Use Scilab, not Matlab 28/68

Page 29: Introduction to Scilab

Submatrix II

B =

! 7. 8. 0. !

! 4. 5. 6. !

! 1. 2. 3. !

Kannan Moudgalya Use Scilab, not Matlab 29/68

Page 30: Introduction to Scilab

Submatrix

-->A

A =

! 1. 2. 3. !

! 1. 4. 7. !

! 7. 8. 0. !

-->B=A(:,2)

B =

! 2. !

! 4. !

! 8. !

Kannan Moudgalya Use Scilab, not Matlab 30/68

Page 31: Introduction to Scilab

Submatrix I

-->b=[5 -3;2 -4]

b =

! 5. - 3. !

! 2. - 4. !

-->x=abs(b)>2

Kannan Moudgalya Use Scilab, not Matlab 31/68

Page 32: Introduction to Scilab

Submatrix II

x =

! T T !

! F T !

-->y=b(abs(b)>2)

y =

! 5. !

! - 3. !

! - 4. !

Kannan Moudgalya Use Scilab, not Matlab 32/68

Page 33: Introduction to Scilab

Special Matrices I

-->zeros(3,3)

ans =

! 0. 0. 0. !

! 0. 0. 0. !

! 0. 0. 0. !

-->ones(2,4)

Kannan Moudgalya Use Scilab, not Matlab 33/68

Page 34: Introduction to Scilab

Special Matrices II

ans =

! 1. 1. 1. 1. !

! 1. 1. 1. 1. !

-->rand(2,1)

ans =

! 0.2113249 !

! 0.7560439 !

Kannan Moudgalya Use Scilab, not Matlab 34/68

Page 35: Introduction to Scilab

Go for Vector Computation

Kannan Moudgalya Use Scilab, not Matlab 35/68

Page 36: Introduction to Scilab

Go for Vector Computation I

-->a = ones(10000,1);

-->timer()

ans =

0.02

-->for i = 1:10000, b(i)=a(i)+a(i); end

-->timer()

Kannan Moudgalya Use Scilab, not Matlab 36/68

Page 37: Introduction to Scilab

Go for Vector Computation II

ans =

0.31

-->c = a+a;

-->timer()

ans =

0.03

Kannan Moudgalya Use Scilab, not Matlab 37/68

Page 38: Introduction to Scilab

Plots

Go through the Demos!

Kannan Moudgalya Use Scilab, not Matlab 38/68

Page 39: Introduction to Scilab

Comparing Matlab and Scilab

I Capability comparison - a correctquestion?

I Is Matlab required for class students?

I Matlab and versions

I Mathworks: 2,000 employees

I Scilab: 23 full time employees

Kannan Moudgalya Use Scilab, not Matlab 39/68

Page 40: Introduction to Scilab

Hardware Interfacing through FOSS

I ScilabI Xcos, HART, COMEDI

I GNURadio

Kannan Moudgalya Use Scilab, not Matlab 40/68

Page 41: Introduction to Scilab

Scilab for Hardware Interfacing

I COMEDI has device drivers for 150 A/Dand Digital I/O cards

I We can call ALL of them from ScilabI Using Xcos (' Simulink), HART

I Devices not in COMEDI, but with Cdrivers

I Devices without device drivers

Kannan Moudgalya Use Scilab, not Matlab 41/68

Page 42: Introduction to Scilab

GNURadio for Hardware Interfacing

I Open source software

I Uses C++ and Python

I Can call OpenCVI Has graphic front end

I Has sliders, etc. - allows change ofparameters in real time

I Calling Scilab functions from GNURadioI Calling Xcos functions from GNURadio

I LabView does not allow Simulink calls!

Kannan Moudgalya Use Scilab, not Matlab 42/68

Page 43: Introduction to Scilab

Control of Single Board Heater Systemthrough Scilab and GNURadio

Kannan Moudgalya Use Scilab, not Matlab 43/68

Page 44: Introduction to Scilab

Replacement for ORCAD?

I KiCAD + NGSpice + ... – a replacementfor ORCAD?

Kannan Moudgalya Use Scilab, not Matlab 44/68

Page 45: Introduction to Scilab

SAGE - a Replacement for Mathematica

Kannan Moudgalya Use Scilab, not Matlab 45/68

Page 46: Introduction to Scilab

OpenFoam - a Replacement for Fluent

Kannan Moudgalya Use Scilab, not Matlab 46/68

Page 47: Introduction to Scilab

Other Projects

Kannan Moudgalya Use Scilab, not Matlab 47/68

Page 48: Introduction to Scilab

Lab migration project: Matlab to Scilab

I Help code lab assignments into ScilabI Examples:

I IIT BombayI Delhi UniversityI SASTRA UniversityI Anna UniversityI The list is growing

Kannan Moudgalya Use Scilab, not Matlab 48/68

Page 49: Introduction to Scilab

Problems with open source software

I Good documents are missing

I Lack of support

I Wrong impression about the quality

Kannan Moudgalya Use Scilab, not Matlab 49/68

Page 50: Introduction to Scilab

Textbook Companion Project

Kannan Moudgalya Use Scilab, not Matlab 50/68

Page 51: Introduction to Scilab

Textbook Companion Project

I Creation of documents is difficult

I Code creation is easier

I Create code for existing documents

Kannan Moudgalya Use Scilab, not Matlab 51/68

Page 52: Introduction to Scilab

Textbook Companion Project

I Choose any standard textbook

I Code worked out examples into Scilab

I Get the correctness certified by thesubject expert

I Get honorarium - Rs. 10,000

I Summer internship to create textbookcompanion

I See the web page

Kannan Moudgalya Use Scilab, not Matlab 52/68

Page 53: Introduction to Scilab

Internship project during summer of 2010

I Fluid mechanics by Fox and McDonald -NIT Trichy, 4th year B.E. student

I Control system design by Smarajit Ghosh- NIT Srinagar, 4th year B.E. student

I Engg. mathematics by Kreyszig - BITRanchi, 2nd year B.E. student

I Three more created by IIT Bombaystudents

Kannan Moudgalya Use Scilab, not Matlab 53/68

Page 54: Introduction to Scilab

Textbook companions created by CollegeProfessors

I Prof. Raajan, SASTRA UniversityI Digital image processing by Gonsalves

I Prof. Senthilkumar, IRTT, ErodeI Signals and Systems by Oppenheim, Willsky

and YoungI DSP by Proakis and ManolakisI Optical communication by KeiserI Electromagnetics - in pipeline

Kannan Moudgalya Use Scilab, not Matlab 54/68

Page 55: Introduction to Scilab

List of books for companion project

I Completed books - 100

I Books in progress - 50

I Expect many summer interns to do this

I See the web page

Kannan Moudgalya Use Scilab, not Matlab 55/68

Page 56: Introduction to Scilab

Availability

I Every textbook companion is available asa pdf file

I Can be downloaded free of cost fromscilab.in

I Can be printed as a book as well -samples will be shown to you

I Need the original textbook to understand

I No copyright violation

Kannan Moudgalya Use Scilab, not Matlab 56/68

Page 57: Introduction to Scilab

Spoken Tutorials

Kannan Moudgalya Use Scilab, not Matlab 57/68

Page 58: Introduction to Scilab

Spoken Tutorials

I It is an instructional methodology

I Based on IT

I Available also in local languages

I Available free of cost - thanks to MHRDfunding

I Will help bridge digital divide

I Make our country IT literate

I Make our children employable

Kannan Moudgalya Use Scilab, not Matlab 58/68

Page 59: Introduction to Scilab

Demo of creating a spoken tutorial

Kannan Moudgalya Use Scilab, not Matlab 59/68

Page 60: Introduction to Scilab

What is a Spoken Tutorial?

I It is a recording of a computer session,along with a running commentary

I It is an audio-video tutorial

I It is typically ten minutes long

I Suitable for self learning

Kannan Moudgalya Use Scilab, not Matlab 60/68

Page 61: Introduction to Scilab

Target Audience

A remote child, working alone, at midnight,without anyone to help her

Kannan Moudgalya Use Scilab, not Matlab 61/68

Page 62: Introduction to Scilab

Steps in creating spoken tutorials

I Outline for a software by an expert

I Script for a tutorial by an expert

I Novice check

I Recording

I Verification and acceptance

I Translation of spoken part into otherlanguages

I Dubbing the voice

Kannan Moudgalya Use Scilab, not Matlab 62/68

Page 63: Introduction to Scilab

Dubbing into Our Languages

I Dub only audio

I Video remains the same

I If original spoken tutorial is made properly,dubbing is easy

Kannan Moudgalya Use Scilab, not Matlab 63/68

Page 64: Introduction to Scilab

Benefits of dubbing

I Useful for students weak in EnglishI esp. school students in vernacular medium

I Can provide high technology solutions toeven minority population groups

Kannan Moudgalya Use Scilab, not Matlab 64/68

Page 65: Introduction to Scilab

Sample Tutorials in Our Languages

Assamese (dubbing) Bodo (geo)Bengali (Sci) Bhojpuri (dubbing)Indian English (PHP) Gujarati (Xfig)Hindi (Linux) Kannada (CS)Khasi (CS) Konkani (CS)Malayalam (dubbing) Marathi (Sci)Mythili (CS) Oriya (dubbing)Rajasthani (CS) Sanskrit (LATEX)Sindhi (CS) Tamil (LATEX)Telugu (Sci) Urdu (Sci)

Kannan Moudgalya Use Scilab, not Matlab 65/68

Page 66: Introduction to Scilab

Conclusion

I Open source efforts are not only idealistic,but make economic and commercial senseas well

I It has a potential to empower ALL Indianchildren to collaborate and make us adeveloped nation

I IIT Bombay is working on several opensource projects

I We invite you to join us

Kannan Moudgalya Use Scilab, not Matlab 66/68

Page 67: Introduction to Scilab

Funding for our work

I Funded by National Mission on Educationthrough ICT, MHRD, Government ofIndia

I http://spoken-tutorial.org/NMEICT-Intro

Kannan Moudgalya Use Scilab, not Matlab 67/68

Page 68: Introduction to Scilab

Thanks

I [email protected] http://spoken-tutorial.org

/What is a spoken tutorial

Kannan Moudgalya Use Scilab, not Matlab 68/68