2 views

Uploaded by Mirasol Salubre

save

- Monitor Pro Tuto2
- 83 Psy s Routines
- m912213e
- ch1
- The Representation of Real Numbers on a Computer
- Programming Abstractions in C++: CS106B Reader
- Ve Hinh Co Ban Trong OpenGL
- 2.2 Module 2 Basic Java Programming Language
- Assignment 1 Problem 2
- Chp7 SHTxx Demo
- Numerical Analysis
- Floating Point Numbers
- Python_Cheat-Sheet.pdf
- DDI0463F_cortex_a7_fpu_r0p5_trm
- Analysis of Parallel Speedups
- Program
- Enhanced Modbus
- Variables and Expressions
- Java Interview Questions
- CUDA C Best Practices Guide
- AgroLogReport
- vishal
- C lab programs - solutions find at www.itstudentjunction.com
- Python Programming for Biology_ - Tim J. Stevens
- Count Vowels From Raw Input
- Python for Lecture V04
- 69878 Cleves Corner Computing Pi 91954v00
- Problem Set 1
- 8_String _ JavaScript Tutorial
- API Specs
- NERI - Clarice e Duras - A Estética Como Subversão Dos Discurso
- Tec de Arco Cello
- Estrutura Do DNA
- Curso Completo de Italiano.pdf
- TEHNIKE SNIMANJA II skripta.docx
- Beast
- Proyecto de Aula Hidrologia
- Carta de Presentacion
- RELACIONES HUMANAS
- GA03 3C2 PEP Camiones Mineros 2017
- Batch Continuo
- Cambodian, Laotian handicraft producers seek export boost at Lifestyle Vietnam.pdf
- Writing Part 3 B1 PET Letter Sport
- Malla Curricular Telematica
- EBF_2018
- RtcE-diseno-curricular-del-nivel-secundario-primer-ciclopdf.pdf
- Alexandre Moraes, ministro do STF, nega liberdade para o presidente Lula
- Los Efectos Del Sonido Durante El Proceso El Aprendizaje Espacial
- polatanam-121231170300-phpapp02
- Clase 10 - Cortante
- Stieg Larsson A Lány Aki a Tűzzel Játszik
- 1816_Theoretic-Arithmetic.pdf
- Mecanisme_de_coping.doc
- Sherwin Guia de Materiales 2017
- Estructura Proyecto de Grado 2018
- Tes
- graficas alb 1.docx
- waaaaaaaaaa.docx
- Kitab Tauhid.pdf
- 25_6_2018_21asd
- Simplified Design Guidelines for Riprap Subjected to Overtopping Flow
- Structural Engineering presentation_Gene.pdf
- DB11-Sub-Philippines.pdf
- Watertank-GS.pdf
- Riprap Design Methods
- Lecture 7- Creating Schedules using PDM.pdf
- storagetanks2010edition.pdf
- A Design Example for a Rectangular Concrete Tank.pdf
- ACI_mix_design.pdf
- Riprap Protection
- Anchor Block Retaining System
- Chapter 4 - The Building Architectural Design.pdf
- h_slabs.pdf
- Detailed-Engineering-Evaluation-Procedure.pdf
- Pump Test Requirements for Ground Water
- technical guidelines for well construction and ground water protection.pdf
- organizing for safety.ppt
- Wiki - Standard Penetration Test
- Visual Inspection Capacity Assessment
- organizing a project.ppt
- Pervious Concrete
- Critical Path Method
- project report sample.doc
- Scilab_calculator.pdf
- L13_FormWk9811

You are on page 1of 12

SCILAB AS A CALCULATOR

The purpose of this tutorial is to get started using Scilab as a basic

calculator by discovering some predefined data types and

functions.

Level

This work is licensed under a Creative Commons Attribution-NonComercial-NoDerivs 3.0 Unported License.

www.openeering.com

how to define a new variable and some operations on numbers. we will see the usage of variables. Step 2: Roadmap In this tutorial. We will apply the acquired competencies for the resolution of a quadratic equation of which we know the solution. Scilab as a Calculator www.openeering.Step 1: The purpose of this tutorial In the tutorial “First steps with Scilab” we have introduced to the user the Scilab environment and its features and here the aim is to make him/her comfortable with Scilab basic operations. after looking over Scilab basic predefined data types and functions available in the environment.com Descriptions Basic commands and operations Predefined variables Arithmetic and formats Variables Functions Example Conclusions and remarks Steps 3-8 9 10-12 13-16 17 18 19-20 page 2/12 .

0.4 www. ans can be used as a normal variable.2 Step 5: Basic mathematical operators Basic mathematical operators: - addition and subtraction: +.4 + 4)/(3-4^0.Step 3: Scilab as a basic calculator Scilab can be directly used to evaluate mathematical expressions. // This is a comment // Let's divide the previous value by two 0.4 + 4/2 ans/2 ans = 2. The slashes as well as all the following characters up to the end of the lines are not interpreted. / - power: ^ - parentheses: () Scilab as a Calculator (0.4 ans is the default variable that stores the result of the last mathematical expression (operation).com page 3/12 .5) // A comment after the command ans = 4.4 + 4/2 ans = 2. - - multiplication and division: *.4 ans = 1. Step 4: Comments A sequence of two consecutive slashes // out of a string definition marks the beginning of a comment.openeering.

// The result is stored in the ans variable ans ans = 2. can be used to split an expression in more than one row. 1/4 + 1/5 + . ans = 2. is used to suppress the output.. i.” The Scilab operator . // Two expressions 1*2 . which will not be displayed in the Console.45 www. 1. The command .” The Scilab operator .3 ans = 2.. can also be used to separate expressions (in general statements. 1/6 ans = 2.Step 6: The Scilab operator “. can be used to separate expressions in the same row..” The Scilab operator ..45 Step 8: The Scilab operator “.com page 4/12 . Step 7: The Scilab operator “.e... Scilab commands) in the same row..openeering.4 // The expression is toooooooo long 1 + 1/2 + 1/3 + .1 + 1. Scilab as a Calculator // An expression 1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6..

openeering. which is the Euler’s constant e - %pi.. sin(%pi) ans = 3. Step 10: Complex arithmetic %i // imaginary unit sqrt(-1) exp(%i*%pi)+1 // The famous Euler relation Also complex arithmetic is available. three of the main variables with a mathematical meaning are - %e. but we get a really close to zero value because of the machine rounding error. several constants and functions already exist and their names begin with a percent character %. is the imaginary unit i On the right we get the imaginary unit also computing the square root of -1 and the Euler relation returns a really close to zero value because of the machine rounding error.1415.. For example.Step 9: Predefined variables .com page 5/12 . %i. which is the mathematical constant - %i. Scilab as a Calculator ans = i ans = i ans = 1.225D-16 In the example on the right we have displayed the value of and its sinus through the use of the Scilab sinus function sin. which is the imaginary number i %pi // pi = 3.. We should obtain .1415927 ans = 1.1/5 In Scilab.225D-16i www.

.openeering. %inf*%inf. !--error 27 Division by zero.. The initial mode value is 0. Scilab as a Calculator ieee(2) // set floating point exceptions for Inf and Nan 1/0 0/0.com page 6/12 ... %inf*%nan ieee(0) // unset floating point exceptions for Inf and Nan 1/0 0/0 ans = Inf ans = Nan ans = Nan ans = Nan !--error 27 Division by zero. the “not a number” value Nan comes from a mathematically undefined operation such as 0/0 and the corresponding variable is %nan.Step 11: Extended arithmetic In Scilab. 0 floating point exception produces an error 1 floating point exception produces a warning 2 floating point exception produces Inf or Nan The command ieee(mod) sets the current floating point exception mode. www. The command ieee() returns the current floating point exception mode. while Inf stands for “infinity” and the corresponding variable is %inf.

20). although the visualization format may be limited. %pi // Change visualization format("v". z-Z ) or the underscore character ( _ ) - Names must not contain blanks and special characters The disp command is used to display data to the console. // Define variable c as expression of a and b c = a*b.14159265358979312 ans = 3.10).Step 12: Change the visualization format All computations are done in double precision arithmetic. Scilab as a Calculator www.20). b = 3/4. // Display the result disp(c) Syntax: name of the variable = expression where expression can involve other variables.openeering.1415926535898D+00 ans = 3. - Variable names can be up to 24 characters long - Variable names are case sensitive (variable A is different from a) - The first letter must be an alphabetic character (a-A.1415927 Step 13: Defining new variables // Define variables a and b a = 4/3. while 'v' sets the variable one. Some constraints: 1. %pi // Restore original visualization ans = 3.com page 7/12 . We can also choose the number of digits to visualize. %pi // Change visualization format('e'. format('v'. Using the command format the option 'e' sets the e-format.

Hello World! d = Length of Hello is 5 Step 15: Boolean variables Boolean variables are used to store true (%t or %T) or false data (%f or %F) typically obtained from logical expressions. disp(c).Step 14: String variables // Two strings a = 'Hello'. // String concatenation c = a + " " + b + "!" . The comparison operators are: - < : Less than - <= : Less than or equal to - == : Equal to - >= : Greater than or equal to - > : Greater than Scilab as a Calculator // Example of a true expression res = 1>0 // Example of a false expression res = 1<0 res = T res = F www.com page 8/12 . b = 'World'. // Concatenation of a string with a number d = "Length of " + a + " is " + string(length(a)) String variables are delimited by quotes characters of type " or '. The command string converts a number into a string.openeering.

In the Variable Browser we can see that the type of a changes outright: Scilab as a Calculator www.Step 16: Main advantages using Scilab // a contains a number a = 1. In the example on the right we have not declared the type and the size of a: we just assigned the value 1 to the new variable.openeering. we have overwritten the value 1 of type double contained in a with the string Hello! by simply assigning the string to the variable. disp(a) // a is now a string a = 'Hello!'. Hello! Moreover. disp(a) When working with variables in Scilab we have two advantages: - Scilab does not require any kind of declaration or sizing - The assignment operation coincides with the definition 1.com page 9/12 .

.5. sinh.Step 17: Scilab functions Many built-in functions are already available. // Examples of input arguments rand sin(%pi) max(1. floor. cosh.2) [v.2) // Examples of output arguments a = rand v = max(1. tan. cos. acos.2. format.. Field Trigonometry Log .2) max(1...2. the syntax and some examples of usage of that function. isreal. atan. . real. . log10.4. Type in the Console the command help followed by the name of a function to get the description.2.com page 10/12 .4. ieee. as you can see in the table on the right.. asin. imag.5. Commands sin.4..2) Scilab as a Calculator www.exp – power Floating point Complex In the examples on the right you can see different ways to set input and output arguments. . . exp. round. log.k] = max(1.. ceil. sqrt..5.openeering.

If solutions are imaginary. // Compute delta Delta = b^2-4*a*c.0.0 -2.0. c = -1/3.8047379 On the right you can find the implementation and the validation of the numerical solutions with respect to the exact solutions. diff_x2 = 0. // Compute solutions x1 = (-b+sqrt(Delta))/(2*a).0 where the solutions are √ x1e = 0. Scilab as a Calculator www. disp(x2). The well-known solutions of a quadratic equation are √ where .0 -1. 0.8047379 .0/3. x2 = (-b-sqrt(Delta))/(2*a).com page 11/12 .1380712 diff_x1 = 0.1380712 We assess the implementation on the following input data: Coefficient a b c // Exact solutions x1e = (1+sqrt(2))/3 x2e = (1-sqrt(2))/3 // Compute differences between solutions diff_x1 = abs(x1-x1e) diff_x2 = abs(x2-x2e) Value +3. // Display the solutions disp(x1). x2e = . b = -2.Step 18: Example (quadratic equation) // Define input data a = 3.openeering.

com page 12/12 . 2.openeering.scilab.txt example_calculator.com.Step 19: Concluding remarks and References 1.openeering.sce : the license file : examples in this tutorial Anna Bassi.openeering. Step 20: Software content To report a bug or suggest some improvement please contact Openeering team at the web site www.org. in order to make him/her comfortable with Scilab basic operations. Manolo Venturin Scilab as a Calculator www. Thank you for your attention. In this tutorial we have introduced to the user Scilab as a basic calculator.com. Openeering: www. Scilab Web Page: www. ---------------------SCILAB AS A CALCULATOR ----------------------------------Main directory -------------license.

- Monitor Pro Tuto2Uploaded byJose Luna
- 83 Psy s RoutinesUploaded bysatbr
- m912213eUploaded byvenky4025
- ch1Uploaded byRishabh Agarwal
- The Representation of Real Numbers on a ComputerUploaded byrodwellhead
- Programming Abstractions in C++: CS106B ReaderUploaded byshadrech
- Ve Hinh Co Ban Trong OpenGLUploaded byĐào Ngọc
- 2.2 Module 2 Basic Java Programming LanguageUploaded byazphyo
- Assignment 1 Problem 2Uploaded byPeter
- Chp7 SHTxx DemoUploaded byĐỗ Toàn
- Numerical AnalysisUploaded byJaspreetBrar
- Floating Point NumbersUploaded bymm8871
- Python_Cheat-Sheet.pdfUploaded byAnonymous 8KGdHjjqN
- DDI0463F_cortex_a7_fpu_r0p5_trmUploaded byBoda Kishan
- Analysis of Parallel SpeedupsUploaded byWenqi Wu
- ProgramUploaded bymridul05
- Enhanced ModbusUploaded byMaksum Solikhin
- Variables and ExpressionsUploaded byHansHanson3
- Java Interview QuestionsUploaded bymchandri82
- CUDA C Best Practices GuideUploaded by.xml
- AgroLogReportUploaded byAlexandru Grigore Jucan
- vishalUploaded byNikunj Jakhotia
- C lab programs - solutions find at www.itstudentjunction.comUploaded byganesh_krishna
- Python Programming for Biology_ - Tim J. StevensUploaded byphyaravi
- Count Vowels From Raw InputUploaded byMackenzie Lewerke
- Python for Lecture V04Uploaded byGerhard Brunthaler
- 69878 Cleves Corner Computing Pi 91954v00Uploaded byklumer_x
- Problem Set 1Uploaded byali
- 8_String _ JavaScript TutorialUploaded byFachrul Andy
- API SpecsUploaded byAkash Rajput

- Simplified Design Guidelines for Riprap Subjected to Overtopping FlowUploaded byMirasol Salubre
- Structural Engineering presentation_Gene.pdfUploaded byMirasol Salubre
- DB11-Sub-Philippines.pdfUploaded byMirasol Salubre
- Watertank-GS.pdfUploaded byMirasol Salubre
- Riprap Design MethodsUploaded byMirasol Salubre
- Lecture 7- Creating Schedules using PDM.pdfUploaded byMirasol Salubre
- storagetanks2010edition.pdfUploaded byMirasol Salubre
- A Design Example for a Rectangular Concrete Tank.pdfUploaded byMirasol Salubre
- ACI_mix_design.pdfUploaded byMirasol Salubre
- Riprap ProtectionUploaded byMirasol Salubre
- Anchor Block Retaining SystemUploaded byMirasol Salubre
- Chapter 4 - The Building Architectural Design.pdfUploaded byMirasol Salubre
- h_slabs.pdfUploaded byMirasol Salubre
- Detailed-Engineering-Evaluation-Procedure.pdfUploaded byMirasol Salubre
- Pump Test Requirements for Ground WaterUploaded byMirasol Salubre
- technical guidelines for well construction and ground water protection.pdfUploaded byMirasol Salubre
- organizing for safety.pptUploaded byMirasol Salubre
- Wiki - Standard Penetration TestUploaded byMirasol Salubre
- Visual Inspection Capacity AssessmentUploaded byMirasol Salubre
- organizing a project.pptUploaded byMirasol Salubre
- Pervious ConcreteUploaded byMirasol Salubre
- Critical Path MethodUploaded byMirasol Salubre
- project report sample.docUploaded byMirasol Salubre
- Scilab_calculator.pdfUploaded byMirasol Salubre
- L13_FormWk9811Uploaded byMirasol Salubre