Successfully reported this slideshow.
Upcoming SlideShare
×

Scilab: Computing Tool For Engineers

1,509 views

Published on

Basics of Free and Open Source Computing Tool Scilab for I and II year Engineering Graduates (across all streams)

Published in: Education
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Scilab: Computing Tool For Engineers

1. 1. Scilab: Computing Tool for Engineers P. R. Naren School of Chemical & Biotechnology SASTRA University E-mail: prnaren@scbt.sastra.edu National Conference on Advances in Process Engineering CAPE-2015 SASTRA University Thanjavur, Tamilnadu 613 401 INDIA 9th October 2015 Progress Through Quality Education
2. 2. Why are we here? • To learn about Scilab – Syntax – Advantages – Limitation • To master programming skills • To become efficient programmer Familiarize programming tool Scilab and complement our learning process ! 9-Oct-15 Scilab - A Computing Tool for Engineers 2
3. 3. Outline • What is Scilab ? • Basics – Variables, Matrices, – Std. I/O function • Linear algebra • Functions and Subroutines • Control / Looping statements • ODE • File operations and GUI • Plot Functions 9-Oct-15 Scilab - A Computing Tool for Engineers 3
4. 4. Scilab • Computing tool – Scripts / programming environment – Mathematical operations A place where we can compute / calculate !!! Numerically solve equations • Free and Open source http://www.scilab.org – Free to download – Lot of help material available over net http://wiki.scilab.org/ http://help.scilab.org/docs/5.5.2/en_US/index.html 9-Oct-15 Scilab - A Computing Tool for Engineers 4
5. 5. FOSSEE Project • Free and Open Source Software for Education • FOSSEE on Scilab: http://www.scilab.in – Spoken Tutorials 10 min short videos on scilab functions http://spoken-tutorial.org/ Take workshop and attend objective test IITB MHRD certificate – Textbook Companion Project http://www.scilab.in/Textbook_Companion_Project  Code all solved examples of standard textbook – Codes for most textbooks already available – Use and learn !! Get paid ! Honorarium (INR 12k) from IITB – Lab Migration Project Convert lab exercises to Scilab 9-Oct-15 Scilab - A Computing Tool for Engineers 5
6. 6. Familiarization • Version 5.5.2 Console Variable List Command History File Browser 9-Oct-15 Scilab - A Computing Tool for Engineers 6
7. 7. Basic Operators and Functions • Operators : +, -, *, /, ^ • sqrt • %e • %i • %pi • log – This is based on “e” - Natural logarithm • log10 • Colon “:” operator • sin cos tan – sind cosd tand – asin acos atan • factorial • sum • product • Relational – > >= < <= == ~= <> • Logical – & | ~ 9-Oct-15 Scilab - A Computing Tool for Engineers 7
8. 8. Variables • No class/type definitions or declarations -->a = 3; -->a a = 3. -->a = "Workshop"; -->a a = Workshop 9-Oct-15 Scilab - A Computing Tool for Engineers 8
9. 9. Matrices • Every variable is n dimension in nature – No need to specify the dimensions / length / size h = [ 1 24 -5] -->h = [1 24 -5] h = 1. 24. - 5. -->h = 1; -->h(1,2) = 24; -->h(1,3) = - 5; -->h h = 1. 24. - 5. -->h = [1 24]; -->h(1,3) = - 5; -->h h = 1. 24. - 5. 9-Oct-15 Scilab - A Computing Tool for Engineers 9
10. 10. Matrices Cont. -->x = [2 -3 4; 5 10 24] x = 2. - 3. 4. 5. 10. 24. -->x = [2 -3 4]; -->x(2,:) = [5 10 24]; -->x x = 2. - 3. 4. 5. 10. 24. -->x(2,:) = [5 10 24]; -->x x = 0. 0. 0. 5. 10. 24. -->x(1,:)=[2 -3 4] x = 2. - 3. 4. 5. 10. 24. 9-Oct-15 Scilab - A Computing Tool for Engineers 10
11. 11. Script Files • Script file – .sce – .sci  e - executable i – functions  e – main script files i - for functions or sub-rountines • “//” comment a statement – Good programing etiquettes ! • clc • clear 9-Oct-15 Scilab - A Computing Tool for Engineers 11
12. 12. Tutorials • Tut1: Product of two nos. • Tut2: Product of two nos. + user input • Tut3: Matrix calculations based on user choice • Tut4: Matrix calculations based on user choice with condition check • Tut5: Spline curves • Tut6: Building blocks • Tut7: Equation of motion : v • Tut8: Equation of motion: v and x • Tut9: Roots of polynomial • Tut10: Smart Input for Tut4 • Tut11: Write output into text file • Tut12: Sum on n numbers • Tut1: Print statements • Tut2: Input function • Tut3: Switch case • Tut4: If then else • Tut5: Plot functions • Tut6: Function (Sub routines) • Tut7: ODE function : I order • Tut8: Simultaneous ODE : Two I order • Tut9: Inbuilt function fsolve • Tut10: GUI • Tut11: File operations • Tut12: For looping 9-Oct-15 Scilab - A Computing Tool for Engineers 12
13. 13. Tutorial 1 Multiplication of two numbers (23.4 and 21) and get their product • Objective – General programming structure clear clc different sections in program – Different options for output (result display on console) disp mprintf Tutorial-1 Script File 9-Oct-15 Scilab - A Computing Tool for Engineers 13
14. 14. Tutorial 2 Multiplication of two numbers (user input) and get their product • Objective – input function Obtain user input and then perform computation  Makes program more generic  reusable !! Tutorial-2 Script File 9-Oct-15 Scilab - A Computing Tool for Engineers 14
15. 15. Tutorial 3 Perform operations on matrix based on user choice • Objective – Control statement – “select – case – end” Obtain two matrices from user  Perform arithmetic operations on the matrices based on user choice – Add two matrix – Matrix multiplication – Element wise multiplication Tutorial-3 Script File 9-Oct-15 Scilab - A Computing Tool for Engineers 15
16. 16. Tutorial 4 Perform operations on matrix based on user choice with conditional check • Objective – Control statement – “if - then – else - end” Obtain two matrices from user  Perform arithmetic operations on the matrices based on user choice – Add two matrix / Matrix multiplication / Element wise multiplication Check whether the user entered value is within bounds / range !! Tutorial-4 Script File 9-Oct-15 Scilab - A Computing Tool for Engineers 16
17. 17. Tutorial 5 Graphical nature of functions • Objective – Plot functions Generate equi-spaced data (data range)  Generate splines – Smooth polynomial Plot the generated spline to know its nature Tutorial-5 Script File 9-Oct-15 Scilab - A Computing Tool for Engineers 17
18. 18. Tutorial 6 Building Block • Objective – Use of sub-routines or functions  Define function once and call it wherever required  Given dimensions of unit building block, how many blocks are required to build a wall Tutorial-6 Script File 9-Oct-15 Scilab - A Computing Tool for Engineers 18
19. 19. Tutorial 7 Equation of motion : Velocity of a moving body under constant linear acceleration • Objective – Solve first order ODE  Equation of motion for a moving body under constant acceleration Acceleration “a” – Constant – Variable Tutorial-7 Script File 0 0t t u u  9-Oct-15 Scilab - A Computing Tool for Engineers 19
20. 20. Tutorial 8 Equation of motion : Velocity and Location of a moving body under constant linear acceleration • Objective – Solve two first order ODE’s  Equation of motion for a moving body under constant acceleration Acceleration “a” – Constant – Variable Tutorial-8 Script File 0 0t t u u  9-Oct-15 Scilab - A Computing Tool for Engineers 20
21. 21. Tutorial 9 Roots of Polynomial • Objective – To determine the roots of polynomial  Find x such that f(x) = 0  Quadratic equation – Define f(x) – Guess a value for xroot such that f (xroot) = 0 – Use in-built function fsolve to determine a actual root Tutorial-9Script File 0 0t t u u  2 0 1 2f (x) a a x a x   9-Oct-15 Scilab - A Computing Tool for Engineers 21
22. 22. Tutorial 10 Perform operations on matrix based on user choice ! Obtain data in Smart Way ! • Objective – Use of simple GUI function to obtain data Avoids error previously encountered in Tutorial 4 ! Tutorial-10 Script File 9-Oct-15 Scilab - A Computing Tool for Engineers 22
23. 23. Tutorial 11 Write output data into a file • Objective – Use file I/O commands and write result into a file  Water tank of known dimensions (B X W X H) at elevated position Z from ground level  Fluid of known density ( r ) Compute Total and specific potential energy Tutorial11-File-operation.sce tank tank t V BW H m V U U mg Z U m   r   9-Oct-15 Scilab - A Computing Tool for Engineers 23
24. 24. Tutorial 12 Sum on N numbers • Objective – Use looping statement – For loop  Determine the sum of N numbers Tutorial12-File-operation.sce N i i 1 S x    9-Oct-15 Scilab - A Computing Tool for Engineers 24
25. 25. To Sum Up • Scilab as computing tool for engineers • Basic arithmetic operations • Computing abilities in Scilab • Generic programming etiquette • Use Tutorials and Web documents • Improvise, learn (re-learn / un-learn) • Use Scilab to complement your engineering education 9-Oct-15 Scilab - A Computing Tool for Engineers 25
26. 26. Gratitude • CAPE-2015 and IIChE Student Chapter – For this wonderful opportunity • PR Team for their registration drive !! • Technical and Infra support team • Audience 9-Oct-15 Scilab - A Computing Tool for Engineers 26
27. 27. THANK YOU A person who never made a mistake never tried anything new - Albert Einstein - 1879 -1955 Entities must not be multiplied beyond necessity - William of Ockham - 12th A.D. 9-Oct-15 Scilab - A Computing Tool for Engineers 27