Like this? Share it with your network

Share

Cape2013 scilab-workshop-19Oct13

on

  • 2,625 views

Overview of computing tool "Scilab"

Overview of computing tool "Scilab"

Statistics

Views

Total Views
2,625
Views on SlideShare
2,614
Embed Views
11

Actions

Likes
0
Downloads
15
Comments
0

2 Embeds 11

https://www.linkedin.com 8
http://www.linkedin.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Console: Simple arithmetic operations can be directly performed on console / Output is displayed on consoleCommand history stores all commands from console !Variable browser window lists all the variable that are currently in use
  • Semi-colon “;” is used to suppress printing / display on the command window. For instance, command “a=3” assigns 3 to variable “a” and also displays the output on consoleIn contrast, “a=3;” assigns 3 to variable a but suppress the display on console
  • Q: How to retrieve the elements of matrix? Extraction of elements from matrixColon “:” operator

Cape2013 scilab-workshop-19Oct13 Presentation Transcript

  • 1. Scilab – A Computing Tool for Engineers P. R. Naren School of Chemical & Biotechnology (SCBT) prnaren@scbt.sastra.edu at National Conference on Advances in Process Engineering CAPE-2013 SASTRA University Thanjavur, Tamilnadu 613 401 INDIA 19th October 2013 Progress Through Quality
  • 2. Why are we here? • To learn about Scilab – Syntax – Advantages – Limitation Familiarize programming tool Scilab and • To master programming skills complement our learning process ! • To become efficient programmer 19-Oct-13 Scilab - A Computing Tool for Engineers 2
  • 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 19-Oct-13 Scilab - A Computing Tool for Engineers 3
  • 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://help.scilab.org/docs/5.4.1/en_US/index.html 19-Oct-13 Scilab - A Computing Tool for Engineers 4
  • 5. Familiarization • Version 5.4.1 Variable List File Browser Console Command History 19-Oct-13 Scilab - A Computing Tool for Engineers 5
  • 6. Basic Operators and Functions • • • • • • Operators : +, -, *, /, ^ sqrt %e %i %pi log – This is based on “e” Natural logarithm • log10 • Colon “:” operator 19-Oct-13 • sin cos tan – sind cosd tand – asin acos atan • • • • factorial sum product Relational – > >= < <= == ~= <> • Logical – &|~ Scilab - A Computing Tool for Engineers 6
  • 7. Variables • No class/type definitions or declarations -->a = 3; -->a a = 3. -->a = "Workshop"; -->a a = Workshop 19-Oct-13 Scilab - A Computing Tool for Engineers 7
  • 8. Matrices • Every variable is n dimension in nature – No need to specify the dimensions / length / size -->h = [1 24 -5] h = -->h = 1; 1. -->h(1,2) = 24; -->h(1,3) = - 5; h = [ 1 24 -5] -->h h = 1. 24. - 5. -->h = [1 24]; -->h(1,3) = - 5; -->h h = 24. - 5. 1. 19-Oct-13 Scilab - A Computing Tool for Engineers 24. - 5. 8
  • 9. Matrices Cont. -->x = [2 -3 4; 5 10 24] x = -->x(2,:) = [5 10 24]; -->x x = 2. - 3. 4. 5. 10. 24. 0. 5. -->x = [2 -3 4]; 0. 0. 10. 24. -->x(1,:)=[2 -3 4] x = -->x(2,:) = [5 10 24]; 2. - 3. 4. 5. 10. 24. -->x x = 2. - 3. 4. 5. 10. 24. 19-Oct-13 Scilab - A Computing Tool for Engineers 9
  • 10. 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 19-Oct-13 Scilab - A Computing Tool for Engineers 10
  • 11. Tutorials • Tut1: Product of two nos. • Tut1: Print statements • Tut2: Product of two nos. + user input • Tut2: Input function • Tut3: Matrix calculations based on user • Tut3: Switch case • Tut4: If then else choice • Tut4: Matrix calculations based on user choice with condition check • Tut5: Spline curves • Tut5: Plot functions • Tut6: Building blocks • Tut6: Function (Sub routines) • Tut7: Equation of motion : v • Tut7: ODE function : I order • Tut8: Equation of motion: v and x • Tut8: Simultaneous ODE : Two I order • Tut9: Roots of polynomial • Tut9: Inbuilt function fsolve • Tut10: Smart Input for Tut4 • Tut10: GUI • Tut11: Write output into text file • Tut11: File operations • Tut12: Sum on n numbers • Tut12: For looping 19-Oct-13 Scilab - A Computing Tool for Engineers 11
  • 12. 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 19-Oct-13 Scilab - A Computing Tool for Engineers 12
  • 13. 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 19-Oct-13 Scilab - A Computing Tool for Engineers 13
  • 14. 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 19-Oct-13 Scilab - A Computing Tool for Engineers 14
  • 15. 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 19-Oct-13 Scilab - A Computing Tool for Engineers 15
  • 16. Tutorial 5 Plot splines • 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 19-Oct-13 Scilab - A Computing Tool for Engineers 16
  • 17. 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 19-Oct-13 Scilab - A Computing Tool for Engineers 17
  • 18. t t0 u u0 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 19-Oct-13 Scilab - A Computing Tool for Engineers 18
  • 19. t t0 u u0 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 19-Oct-13 Scilab - A Computing Tool for Engineers 19
  • 20. t t0 u u0 Tutorial 9 Roots of Polynomial • Objective – To determine the roots of polynomial  Find x such that f(x) = 0  Quadratic equation f (x) a 0 a1 x a 2 x 2 – 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 19-Oct-13 Scilab - A Computing Tool for Engineers 20
  • 21. 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 19-Oct-13 Scilab - A Computing Tool for Engineers 21
  • 22. Tutorial 11 Write output data into a file • Objective – Use file I/O commands and write result into a file  Circular cross section pipe of known (given) diameter D  Fluid of known density ( and viscosity ( ) flowing at specified volumetric flow rate  Compute Reynolds no. Du  If Re <= 2100 Flow is laminar Re 2100 < Re <= 5000 Transition Re > 5000 Turbulent Tutorial11-File-operation.sce 19-Oct-13 Scilab - A Computing Tool for Engineers 22
  • 23. Tutorial 12 Sum on N numbers • Objective – Use looping statement – For loop  Determine the sum of N numbers N S xi i 1 Tutorial12-File-operation.sce 19-Oct-13 Scilab - A Computing Tool for Engineers 23
  • 24. 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 19-Oct-13 Scilab - A Computing Tool for Engineers 24
  • 25. Gratitude • CAPE-2013 – For this wonderful opportunity • PR Team for their registration spree !! • Technical and Infra support team • Audience 19-Oct-13 Scilab - A Computing Tool for Engineers 25
  • 26. 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. 19-Oct-13 Scilab - A Computing Tool for Engineers 26