SlideShare a Scribd company logo
1 of 12
Download to read offline
www.openeering.com
powered by
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.
Scilab as a Calculator www.openeering.com page 2/12
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.
Step 2: Roadmap
In this tutorial, after looking over Scilab basic predefined data types and
functions available in the environment, we will see the usage of variables,
how to define a new variable and some operations on numbers.
We will apply the acquired competencies for the resolution of a quadratic
equation of which we know the solution.
Descriptions Steps
Basic commands and operations 3-8
Predefined variables 9
Arithmetic and formats 10-12
Variables 13-16
Functions 17
Example 18
Conclusions and remarks 19-20
Scilab as a Calculator www.openeering.com page 3/12
Step 3: Scilab as a basic calculator
Scilab can be directly used to evaluate mathematical expressions.
ans is the default variable that stores the result of the last mathematical
expression (operation). ans can be used as a normal variable.
0.4 + 4/2
ans =
2.4
Step 4: Comments
A sequence of two consecutive slashes // out of a string definition marks
the beginning of a comment. The slashes as well as all the following
characters up to the end of the lines are not interpreted.
// This is a comment
// Let's divide the previous value by two
0.4 + 4/2
ans/2
ans =
2.4
ans =
1.2
Step 5: Basic mathematical operators
Basic mathematical operators:
- addition and subtraction: +, -
- multiplication and division: *, /
- power: ^
- parentheses: ()
(0.4 + 4)/(3-4^0.5) // A comment after the command
ans =
4.4
Scilab as a Calculator www.openeering.com page 4/12
Step 6: The Scilab operator “,”
The Scilab operator , can be used to separate expressions in the same
row.
// Two expressions
1*2 , 1.1 + 1.3
ans =
2.
ans =
2.4
Step 7: The Scilab operator “...”
The Scilab operator ... can be used to split an expression in more than
one row.
// The expression is toooooooo long
1 + 1/2 + 1/3 + ...
1/4 + 1/5 + ...
1/6
ans =
2.45
Step 8: The Scilab operator “;”
The Scilab operator ; is used to suppress the output, which will not be
displayed in the Console.
The command ; can also be used to separate expressions (in general
statements, i.e. Scilab commands) in the same row.
// An expression
1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6;
// The result is stored in the ans variable
ans
ans =
2.45
Scilab as a Calculator www.openeering.com page 5/12
Step 9: Predefined variables - 1/5
In Scilab, several constants and functions already exist and their names
begin with a percent character %.
For example, three of the main variables with a mathematical meaning are
- %e, which is the Euler’s constant e
- %pi, which is the mathematical constant
- %i, which is the imaginary number i
In the example on the right we have displayed the value of and its sinus
through the use of the Scilab sinus function sin. We should obtain
, but we get a really close to zero value because of the machine
rounding error.
%pi // pi = 3.1415....
sin(%pi)
ans =
3.1415927
ans =
1.225D-16
Step 10: Complex arithmetic
Also complex arithmetic is available. %i, 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.
%i // imaginary unit
sqrt(-1)
exp(%i*%pi)+1 // The famous Euler relation
ans =
i
ans =
i
ans =
1.225D-16i
Scilab as a Calculator www.openeering.com page 6/12
Step 11: Extended arithmetic
In Scilab, the “not a number” value Nan comes from a mathematically
undefined operation such as 0/0 and the corresponding variable is %nan,
while Inf stands for “infinity” and the corresponding variable is %inf.
The command ieee() returns the current floating point exception mode.
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.
The initial mode value is 0.
ieee(2) // set floating point exceptions for Inf and
Nan
1/0
0/0, %inf*%inf, %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...
!--error 27
Division by zero...
Scilab as a Calculator www.openeering.com page 7/12
Step 12: Change the visualization format
All computations are done in double precision arithmetic, although the
visualization format may be limited.
Using the command format the option 'e' sets the e-format, while 'v'
sets the variable one. We can also choose the number of digits to
visualize.
format('v',20); %pi // Change visualization
format('e',20); %pi // Change visualization
format("v",10); %pi // Restore original visualization
ans =
3.14159265358979312
ans =
3.1415926535898D+00
ans =
3.1415927
Step 13: Defining new variables
Syntax:
name of the variable = expression
where expression can involve other variables.
Some constraints:
- 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, 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 variables a and b
a = 4/3;
b = 3/4;
// Define variable c as expression of a and b
c = a*b;
// Display the result
disp(c)
1.
Scilab as a Calculator www.openeering.com page 8/12
Step 14: String variables
String variables are delimited by quotes characters of type " or '.
The command string converts a number into a string.
// Two strings
a = 'Hello';
b = 'World';
// String concatenation
c = a + " " + b + "!" ;
disp(c);
// Concatenation of a string with a number
d = "Length of " + a + " is " + string(length(a))
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.
The comparison operators are:
- < : Less than
- <= : Less than or equal to
- == : Equal to
- >= : Greater than or equal to
- > : Greater than
// Example of a true expression
res = 1>0
// Example of a false expression
res = 1<0
res =
T
res =
F
Scilab as a Calculator www.openeering.com page 9/12
Step 16: Main advantages using Scilab
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
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.
Moreover, we have overwritten the value 1 of type double contained in a
with the string Hello! by simply assigning the string to the variable.
In the Variable Browser we can see that the type of a changes outright:
// a contains a number
a = 1;
disp(a)
// a is now a string
a = 'Hello!';
disp(a)
1.
Hello!
Scilab as a Calculator www.openeering.com page 10/12
Step 17: Scilab functions
Many built-in functions are already available, as you can see in the table
on the right. Type in the Console the command help followed by the
name of a function to get the description, the syntax and some examples
of usage of that function.
In the examples on the right you can see different ways to set input and
output arguments.
Field Commands
Trigonometry sin, cos, tan, asin, acos, atan,
sinh, cosh, ...
Log - exp – power exp, log, log10, sqrt, ...
Floating point floor, ceil, round, format,
ieee, ...
Complex real, imag, isreal, ...
// Examples of input arguments
rand
sin(%pi)
max(1,2)
max(1,2,5,4,2)
// Examples of output arguments
a = rand
v = max(1,2,5,4,2)
[v,k] = max(1,2,5,4,2)
Scilab as a Calculator www.openeering.com page 11/12
√
√
Step 18: Example (quadratic equation)
The well-known solutions of a quadratic equation
are
where . If solutions are imaginary.
We assess the implementation on the following input data:
Coefficient Value
a +3.0
b -2.0
c -1.0/3.0
where the solutions are
On the right you can find the implementation and the validation of the
numerical solutions with respect to the exact solutions.
// Define input data
a = 3; b = -2; c = -1/3;
// Compute delta
Delta = b^2-4*a*c;
// Compute solutions
x1 = (-b+sqrt(Delta))/(2*a);
x2 = (-b-sqrt(Delta))/(2*a);
// Display the solutions
disp(x1); disp(x2);
0.8047379
- 0.1380712
// 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)
x1e =
0.8047379
x2e =
- 0.1380712
diff_x1 =
0.
diff_x2 =
0.
Scilab as a Calculator www.openeering.com page 12/12
Step 19: Concluding remarks and References
In this tutorial we have introduced to the user Scilab as a basic calculator,
in order to make him/her comfortable with Scilab basic operations.
1. Scilab Web Page: www.scilab.org.
2. Openeering: www.openeering.com.
Step 20: Software content
To report a bug or suggest some improvement please contact Openeering
team at the web site www.openeering.com.
Thank you for your attention,
Anna Bassi, Manolo Venturin
----------------------
SCILAB AS A CALCULATOR
----------------------
--------------
Main directory
--------------
license.txt : the license file
example_calculator.sce : examples in this tutorial

More Related Content

What's hot

Nas net where model learn to generate models
Nas net where model learn to generate modelsNas net where model learn to generate models
Nas net where model learn to generate modelsKhang Pham
 
Pa familje - HEKTOR MALO
Pa familje - HEKTOR MALOPa familje - HEKTOR MALO
Pa familje - HEKTOR MALOFialdoMema
 
Convolutional Neural Network (CNN) - image recognition
Convolutional Neural Network (CNN)  - image recognitionConvolutional Neural Network (CNN)  - image recognition
Convolutional Neural Network (CNN) - image recognitionYUNG-KUEI CHEN
 
GRUPI A - B TESTIM - KLASA VII #MesueseAurela
GRUPI A - B TESTIM - KLASA VII    #MesueseAurelaGRUPI A - B TESTIM - KLASA VII    #MesueseAurela
GRUPI A - B TESTIM - KLASA VII #MesueseAurela#MesueseAurela Elezaj
 
Teoremat e rrethit
Teoremat e rrethitTeoremat e rrethit
Teoremat e rrethitTeutë Domi
 
Matematike e avancuar 1 FUNKSIONET
Matematike e avancuar 1 FUNKSIONETMatematike e avancuar 1 FUNKSIONET
Matematike e avancuar 1 FUNKSIONETXhoana Pepa
 
Export pdf with puppeteer
Export pdf with puppeteerExport pdf with puppeteer
Export pdf with puppeteerKnoldus Inc.
 
10.b sfera i shar
10.b sfera i shar10.b sfera i shar
10.b sfera i sharNarvatk
 
Prejardheja e shiptarve
Prejardheja e shiptarvePrejardheja e shiptarve
Prejardheja e shiptarveJURIST
 
Funksione matematikore
Funksione matematikoreFunksione matematikore
Funksione matematikoreKlea Vyshka
 
Figurat gjeometrike elementare dhe vetite e tyre Hysen Doko
Figurat gjeometrike elementare dhe vetite e tyre Hysen DokoFigurat gjeometrike elementare dhe vetite e tyre Hysen Doko
Figurat gjeometrike elementare dhe vetite e tyre Hysen DokoHysen Doko
 
Lecture 2 Camera Calibration
Lecture 2   Camera CalibrationLecture 2   Camera Calibration
Lecture 2 Camera CalibrationJoaquim Salvi
 
Muzika dhe instrumentet
Muzika dhe instrumentetMuzika dhe instrumentet
Muzika dhe instrumentetAn An
 
Anatomia e syrit
Anatomia e syritAnatomia e syrit
Anatomia e syritDentistry
 
Fizika ne jeten e perditshme
Fizika ne jeten e perditshmeFizika ne jeten e perditshme
Fizika ne jeten e perditshmeAn An
 

What's hot (20)

Nas net where model learn to generate models
Nas net where model learn to generate modelsNas net where model learn to generate models
Nas net where model learn to generate models
 
Pa familje - HEKTOR MALO
Pa familje - HEKTOR MALOPa familje - HEKTOR MALO
Pa familje - HEKTOR MALO
 
Convolutional Neural Network (CNN) - image recognition
Convolutional Neural Network (CNN)  - image recognitionConvolutional Neural Network (CNN)  - image recognition
Convolutional Neural Network (CNN) - image recognition
 
Syprina e trapezit
Syprina e trapezitSyprina e trapezit
Syprina e trapezit
 
GRUPI A - B TESTIM - KLASA VII #MesueseAurela
GRUPI A - B TESTIM - KLASA VII    #MesueseAurelaGRUPI A - B TESTIM - KLASA VII    #MesueseAurela
GRUPI A - B TESTIM - KLASA VII #MesueseAurela
 
Teoremat e rrethit
Teoremat e rrethitTeoremat e rrethit
Teoremat e rrethit
 
Matematike e avancuar 1 FUNKSIONET
Matematike e avancuar 1 FUNKSIONETMatematike e avancuar 1 FUNKSIONET
Matematike e avancuar 1 FUNKSIONET
 
Export pdf with puppeteer
Export pdf with puppeteerExport pdf with puppeteer
Export pdf with puppeteer
 
Naim Frasheri
Naim FrasheriNaim Frasheri
Naim Frasheri
 
10.b sfera i shar
10.b sfera i shar10.b sfera i shar
10.b sfera i shar
 
Active learning
Active learningActive learning
Active learning
 
Prejardheja e shiptarve
Prejardheja e shiptarvePrejardheja e shiptarve
Prejardheja e shiptarve
 
Funksione matematikore
Funksione matematikoreFunksione matematikore
Funksione matematikore
 
Bölüm 6
Bölüm 6Bölüm 6
Bölüm 6
 
Figurat gjeometrike elementare dhe vetite e tyre Hysen Doko
Figurat gjeometrike elementare dhe vetite e tyre Hysen DokoFigurat gjeometrike elementare dhe vetite e tyre Hysen Doko
Figurat gjeometrike elementare dhe vetite e tyre Hysen Doko
 
Projekt kimi
Projekt kimiProjekt kimi
Projekt kimi
 
Lecture 2 Camera Calibration
Lecture 2   Camera CalibrationLecture 2   Camera Calibration
Lecture 2 Camera Calibration
 
Muzika dhe instrumentet
Muzika dhe instrumentetMuzika dhe instrumentet
Muzika dhe instrumentet
 
Anatomia e syrit
Anatomia e syritAnatomia e syrit
Anatomia e syrit
 
Fizika ne jeten e perditshme
Fizika ne jeten e perditshmeFizika ne jeten e perditshme
Fizika ne jeten e perditshme
 

Viewers also liked

Numerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioningNumerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioningScilab
 
First steps with Scilab
First steps with ScilabFirst steps with Scilab
First steps with ScilabScilab
 
Aeraulic toolbox for Xcos
Aeraulic toolbox for XcosAeraulic toolbox for Xcos
Aeraulic toolbox for XcosScilab
 
Data mining
Data miningData mining
Data miningScilab
 
Modeling an ODE: 3 different approaches - Part 1
Modeling an ODE: 3 different approaches - Part 1Modeling an ODE: 3 different approaches - Part 1
Modeling an ODE: 3 different approaches - Part 1Scilab
 
Modeling an ODE: 3 different approaches - Part 2
Modeling an ODE: 3 different approaches - Part 2Modeling an ODE: 3 different approaches - Part 2
Modeling an ODE: 3 different approaches - Part 2Scilab
 
Introduction to Control systems in scilab
Introduction to Control systems in scilabIntroduction to Control systems in scilab
Introduction to Control systems in scilabScilab
 
Introduction to Discrete Probabilities with Scilab - Michaël Baudin, Consort...
Introduction to Discrete Probabilities with Scilab - Michaël Baudin, Consort...Introduction to Discrete Probabilities with Scilab - Michaël Baudin, Consort...
Introduction to Discrete Probabilities with Scilab - Michaël Baudin, Consort...Scilab
 
Numerical analysis using Scilab: Solving nonlinear equations
Numerical analysis using Scilab: Solving nonlinear equationsNumerical analysis using Scilab: Solving nonlinear equations
Numerical analysis using Scilab: Solving nonlinear equationsScilab
 
Numerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationNumerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationScilab
 
Programa para calcular valores de resistencias
Programa para calcular valores de resistenciasPrograma para calcular valores de resistencias
Programa para calcular valores de resistenciasUlises Hernandez
 

Viewers also liked (11)

Numerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioningNumerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioning
 
First steps with Scilab
First steps with ScilabFirst steps with Scilab
First steps with Scilab
 
Aeraulic toolbox for Xcos
Aeraulic toolbox for XcosAeraulic toolbox for Xcos
Aeraulic toolbox for Xcos
 
Data mining
Data miningData mining
Data mining
 
Modeling an ODE: 3 different approaches - Part 1
Modeling an ODE: 3 different approaches - Part 1Modeling an ODE: 3 different approaches - Part 1
Modeling an ODE: 3 different approaches - Part 1
 
Modeling an ODE: 3 different approaches - Part 2
Modeling an ODE: 3 different approaches - Part 2Modeling an ODE: 3 different approaches - Part 2
Modeling an ODE: 3 different approaches - Part 2
 
Introduction to Control systems in scilab
Introduction to Control systems in scilabIntroduction to Control systems in scilab
Introduction to Control systems in scilab
 
Introduction to Discrete Probabilities with Scilab - Michaël Baudin, Consort...
Introduction to Discrete Probabilities with Scilab - Michaël Baudin, Consort...Introduction to Discrete Probabilities with Scilab - Michaël Baudin, Consort...
Introduction to Discrete Probabilities with Scilab - Michaël Baudin, Consort...
 
Numerical analysis using Scilab: Solving nonlinear equations
Numerical analysis using Scilab: Solving nonlinear equationsNumerical analysis using Scilab: Solving nonlinear equations
Numerical analysis using Scilab: Solving nonlinear equations
 
Numerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationNumerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagation
 
Programa para calcular valores de resistencias
Programa para calcular valores de resistenciasPrograma para calcular valores de resistencias
Programa para calcular valores de resistencias
 

Similar to Scilab as a calculator

MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1Elaf A.Saeed
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013amanabr
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Kurmendra Singh
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Dushmanta Nath
 
Basic of octave matlab programming language
Basic of octave matlab programming languageBasic of octave matlab programming language
Basic of octave matlab programming languageAulia Khalqillah
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++sunny khan
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of PrecedenceMuhammad Hammad Waseem
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2bilawalali74
 
Simplex Algorithm
Simplex AlgorithmSimplex Algorithm
Simplex AlgorithmAizaz Ahmad
 
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...Naoki Shibata
 

Similar to Scilab as a calculator (20)

MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx
 
Basic of octave matlab programming language
Basic of octave matlab programming languageBasic of octave matlab programming language
Basic of octave matlab programming language
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
Basics of c++
Basics of c++ Basics of c++
Basics of c++
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
03. Week 03.pptx
03. Week 03.pptx03. Week 03.pptx
03. Week 03.pptx
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
 
Simplex algorithm
Simplex algorithmSimplex algorithm
Simplex algorithm
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Perl
PerlPerl
Perl
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
 
Simplex Algorithm
Simplex AlgorithmSimplex Algorithm
Simplex Algorithm
 
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
 
Using matlab simulink
Using matlab simulinkUsing matlab simulink
Using matlab simulink
 

More from Scilab

Statistical Analysis for Robust Design
Statistical Analysis for Robust DesignStatistical Analysis for Robust Design
Statistical Analysis for Robust DesignScilab
 
Electric motor optimization
Electric motor optimizationElectric motor optimization
Electric motor optimizationScilab
 
Asteroidlanding - Scilab conference 2019 Keynote
Asteroidlanding - Scilab conference 2019 KeynoteAsteroidlanding - Scilab conference 2019 Keynote
Asteroidlanding - Scilab conference 2019 KeynoteScilab
 
Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...
Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...
Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...Scilab
 
Scilab and Xcos for Very Low Earth Orbits satellites modelling
Scilab and Xcos for Very Low Earth Orbits satellites modellingScilab and Xcos for Very Low Earth Orbits satellites modelling
Scilab and Xcos for Very Low Earth Orbits satellites modellingScilab
 
X2C -a tool for model-based control development and automated code generation...
X2C -a tool for model-based control development and automated code generation...X2C -a tool for model-based control development and automated code generation...
X2C -a tool for model-based control development and automated code generation...Scilab
 
A Real-Time Interface for Xcos – an illustrative demonstration using a batter...
A Real-Time Interface for Xcos – an illustrative demonstration using a batter...A Real-Time Interface for Xcos – an illustrative demonstration using a batter...
A Real-Time Interface for Xcos – an illustrative demonstration using a batter...Scilab
 
Aircraft Simulation Model and Flight Control Laws Design Using Scilab and XCos
Aircraft Simulation Model and Flight Control Laws Design Using Scilab and XCosAircraft Simulation Model and Flight Control Laws Design Using Scilab and XCos
Aircraft Simulation Model and Flight Control Laws Design Using Scilab and XCosScilab
 
Scilab for real dummies j.heikell - part3
Scilab for real dummies j.heikell - part3Scilab for real dummies j.heikell - part3
Scilab for real dummies j.heikell - part3Scilab
 
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab
 
Scilab for real dummies j.heikell - part 1
Scilab for real dummies j.heikell - part 1Scilab for real dummies j.heikell - part 1
Scilab for real dummies j.heikell - part 1Scilab
 
Multiobjective optimization and Genetic algorithms in Scilab
Multiobjective optimization and Genetic algorithms in ScilabMultiobjective optimization and Genetic algorithms in Scilab
Multiobjective optimization and Genetic algorithms in ScilabScilab
 
Scilab optimization workshop
Scilab optimization workshop Scilab optimization workshop
Scilab optimization workshop Scilab
 
INRA @ Scilab Conference 2018
INRA @ Scilab Conference 2018INRA @ Scilab Conference 2018
INRA @ Scilab Conference 2018Scilab
 
Qualcomm @ Scilab Conference 2018
Qualcomm @ Scilab Conference 2018Qualcomm @ Scilab Conference 2018
Qualcomm @ Scilab Conference 2018Scilab
 
Sanofi @ Scilab Conference 2018
Sanofi @ Scilab Conference 2018Sanofi @ Scilab Conference 2018
Sanofi @ Scilab Conference 2018Scilab
 
University of Applied Science Esslingen @ Scilab Conference 2018
University of Applied Science Esslingen @ Scilab Conference 2018University of Applied Science Esslingen @ Scilab Conference 2018
University of Applied Science Esslingen @ Scilab Conference 2018Scilab
 
DLR @ Scilab Conference 2018
DLR @ Scilab Conference 2018DLR @ Scilab Conference 2018
DLR @ Scilab Conference 2018Scilab
 
Fraunhofer IIS @ Scilab Conference 2018
Fraunhofer IIS @ Scilab Conference 2018Fraunhofer IIS @ Scilab Conference 2018
Fraunhofer IIS @ Scilab Conference 2018Scilab
 
Arcelormittal @ Scilab Conference 2018
Arcelormittal @ Scilab Conference 2018Arcelormittal @ Scilab Conference 2018
Arcelormittal @ Scilab Conference 2018Scilab
 

More from Scilab (20)

Statistical Analysis for Robust Design
Statistical Analysis for Robust DesignStatistical Analysis for Robust Design
Statistical Analysis for Robust Design
 
Electric motor optimization
Electric motor optimizationElectric motor optimization
Electric motor optimization
 
Asteroidlanding - Scilab conference 2019 Keynote
Asteroidlanding - Scilab conference 2019 KeynoteAsteroidlanding - Scilab conference 2019 Keynote
Asteroidlanding - Scilab conference 2019 Keynote
 
Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...
Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...
Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm devel...
 
Scilab and Xcos for Very Low Earth Orbits satellites modelling
Scilab and Xcos for Very Low Earth Orbits satellites modellingScilab and Xcos for Very Low Earth Orbits satellites modelling
Scilab and Xcos for Very Low Earth Orbits satellites modelling
 
X2C -a tool for model-based control development and automated code generation...
X2C -a tool for model-based control development and automated code generation...X2C -a tool for model-based control development and automated code generation...
X2C -a tool for model-based control development and automated code generation...
 
A Real-Time Interface for Xcos – an illustrative demonstration using a batter...
A Real-Time Interface for Xcos – an illustrative demonstration using a batter...A Real-Time Interface for Xcos – an illustrative demonstration using a batter...
A Real-Time Interface for Xcos – an illustrative demonstration using a batter...
 
Aircraft Simulation Model and Flight Control Laws Design Using Scilab and XCos
Aircraft Simulation Model and Flight Control Laws Design Using Scilab and XCosAircraft Simulation Model and Flight Control Laws Design Using Scilab and XCos
Aircraft Simulation Model and Flight Control Laws Design Using Scilab and XCos
 
Scilab for real dummies j.heikell - part3
Scilab for real dummies j.heikell - part3Scilab for real dummies j.heikell - part3
Scilab for real dummies j.heikell - part3
 
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2
 
Scilab for real dummies j.heikell - part 1
Scilab for real dummies j.heikell - part 1Scilab for real dummies j.heikell - part 1
Scilab for real dummies j.heikell - part 1
 
Multiobjective optimization and Genetic algorithms in Scilab
Multiobjective optimization and Genetic algorithms in ScilabMultiobjective optimization and Genetic algorithms in Scilab
Multiobjective optimization and Genetic algorithms in Scilab
 
Scilab optimization workshop
Scilab optimization workshop Scilab optimization workshop
Scilab optimization workshop
 
INRA @ Scilab Conference 2018
INRA @ Scilab Conference 2018INRA @ Scilab Conference 2018
INRA @ Scilab Conference 2018
 
Qualcomm @ Scilab Conference 2018
Qualcomm @ Scilab Conference 2018Qualcomm @ Scilab Conference 2018
Qualcomm @ Scilab Conference 2018
 
Sanofi @ Scilab Conference 2018
Sanofi @ Scilab Conference 2018Sanofi @ Scilab Conference 2018
Sanofi @ Scilab Conference 2018
 
University of Applied Science Esslingen @ Scilab Conference 2018
University of Applied Science Esslingen @ Scilab Conference 2018University of Applied Science Esslingen @ Scilab Conference 2018
University of Applied Science Esslingen @ Scilab Conference 2018
 
DLR @ Scilab Conference 2018
DLR @ Scilab Conference 2018DLR @ Scilab Conference 2018
DLR @ Scilab Conference 2018
 
Fraunhofer IIS @ Scilab Conference 2018
Fraunhofer IIS @ Scilab Conference 2018Fraunhofer IIS @ Scilab Conference 2018
Fraunhofer IIS @ Scilab Conference 2018
 
Arcelormittal @ Scilab Conference 2018
Arcelormittal @ Scilab Conference 2018Arcelormittal @ Scilab Conference 2018
Arcelormittal @ Scilab Conference 2018
 

Recently uploaded

CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxVelmuruganTECE
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESNarmatha D
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfRajuKanojiya4
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptxNikhil Raut
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsDILIPKUMARMONDAL6
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 

Recently uploaded (20)

CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptx
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIES
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptx
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teams
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 

Scilab as a calculator

  • 1. www.openeering.com powered by 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.
  • 2. Scilab as a Calculator www.openeering.com page 2/12 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. Step 2: Roadmap In this tutorial, after looking over Scilab basic predefined data types and functions available in the environment, we will see the usage of variables, how to define a new variable and some operations on numbers. We will apply the acquired competencies for the resolution of a quadratic equation of which we know the solution. Descriptions Steps Basic commands and operations 3-8 Predefined variables 9 Arithmetic and formats 10-12 Variables 13-16 Functions 17 Example 18 Conclusions and remarks 19-20
  • 3. Scilab as a Calculator www.openeering.com page 3/12 Step 3: Scilab as a basic calculator Scilab can be directly used to evaluate mathematical expressions. ans is the default variable that stores the result of the last mathematical expression (operation). ans can be used as a normal variable. 0.4 + 4/2 ans = 2.4 Step 4: Comments A sequence of two consecutive slashes // out of a string definition marks the beginning of a comment. The slashes as well as all the following characters up to the end of the lines are not interpreted. // This is a comment // Let's divide the previous value by two 0.4 + 4/2 ans/2 ans = 2.4 ans = 1.2 Step 5: Basic mathematical operators Basic mathematical operators: - addition and subtraction: +, - - multiplication and division: *, / - power: ^ - parentheses: () (0.4 + 4)/(3-4^0.5) // A comment after the command ans = 4.4
  • 4. Scilab as a Calculator www.openeering.com page 4/12 Step 6: The Scilab operator “,” The Scilab operator , can be used to separate expressions in the same row. // Two expressions 1*2 , 1.1 + 1.3 ans = 2. ans = 2.4 Step 7: The Scilab operator “...” The Scilab operator ... can be used to split an expression in more than one row. // The expression is toooooooo long 1 + 1/2 + 1/3 + ... 1/4 + 1/5 + ... 1/6 ans = 2.45 Step 8: The Scilab operator “;” The Scilab operator ; is used to suppress the output, which will not be displayed in the Console. The command ; can also be used to separate expressions (in general statements, i.e. Scilab commands) in the same row. // An expression 1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6; // The result is stored in the ans variable ans ans = 2.45
  • 5. Scilab as a Calculator www.openeering.com page 5/12 Step 9: Predefined variables - 1/5 In Scilab, several constants and functions already exist and their names begin with a percent character %. For example, three of the main variables with a mathematical meaning are - %e, which is the Euler’s constant e - %pi, which is the mathematical constant - %i, which is the imaginary number i In the example on the right we have displayed the value of and its sinus through the use of the Scilab sinus function sin. We should obtain , but we get a really close to zero value because of the machine rounding error. %pi // pi = 3.1415.... sin(%pi) ans = 3.1415927 ans = 1.225D-16 Step 10: Complex arithmetic Also complex arithmetic is available. %i, 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. %i // imaginary unit sqrt(-1) exp(%i*%pi)+1 // The famous Euler relation ans = i ans = i ans = 1.225D-16i
  • 6. Scilab as a Calculator www.openeering.com page 6/12 Step 11: Extended arithmetic In Scilab, the “not a number” value Nan comes from a mathematically undefined operation such as 0/0 and the corresponding variable is %nan, while Inf stands for “infinity” and the corresponding variable is %inf. The command ieee() returns the current floating point exception mode. 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. The initial mode value is 0. ieee(2) // set floating point exceptions for Inf and Nan 1/0 0/0, %inf*%inf, %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... !--error 27 Division by zero...
  • 7. Scilab as a Calculator www.openeering.com page 7/12 Step 12: Change the visualization format All computations are done in double precision arithmetic, although the visualization format may be limited. Using the command format the option 'e' sets the e-format, while 'v' sets the variable one. We can also choose the number of digits to visualize. format('v',20); %pi // Change visualization format('e',20); %pi // Change visualization format("v",10); %pi // Restore original visualization ans = 3.14159265358979312 ans = 3.1415926535898D+00 ans = 3.1415927 Step 13: Defining new variables Syntax: name of the variable = expression where expression can involve other variables. Some constraints: - 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, 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 variables a and b a = 4/3; b = 3/4; // Define variable c as expression of a and b c = a*b; // Display the result disp(c) 1.
  • 8. Scilab as a Calculator www.openeering.com page 8/12 Step 14: String variables String variables are delimited by quotes characters of type " or '. The command string converts a number into a string. // Two strings a = 'Hello'; b = 'World'; // String concatenation c = a + " " + b + "!" ; disp(c); // Concatenation of a string with a number d = "Length of " + a + " is " + string(length(a)) 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. The comparison operators are: - < : Less than - <= : Less than or equal to - == : Equal to - >= : Greater than or equal to - > : Greater than // Example of a true expression res = 1>0 // Example of a false expression res = 1<0 res = T res = F
  • 9. Scilab as a Calculator www.openeering.com page 9/12 Step 16: Main advantages using Scilab 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 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. Moreover, we have overwritten the value 1 of type double contained in a with the string Hello! by simply assigning the string to the variable. In the Variable Browser we can see that the type of a changes outright: // a contains a number a = 1; disp(a) // a is now a string a = 'Hello!'; disp(a) 1. Hello!
  • 10. Scilab as a Calculator www.openeering.com page 10/12 Step 17: Scilab functions Many built-in functions are already available, as you can see in the table on the right. Type in the Console the command help followed by the name of a function to get the description, the syntax and some examples of usage of that function. In the examples on the right you can see different ways to set input and output arguments. Field Commands Trigonometry sin, cos, tan, asin, acos, atan, sinh, cosh, ... Log - exp – power exp, log, log10, sqrt, ... Floating point floor, ceil, round, format, ieee, ... Complex real, imag, isreal, ... // Examples of input arguments rand sin(%pi) max(1,2) max(1,2,5,4,2) // Examples of output arguments a = rand v = max(1,2,5,4,2) [v,k] = max(1,2,5,4,2)
  • 11. Scilab as a Calculator www.openeering.com page 11/12 √ √ Step 18: Example (quadratic equation) The well-known solutions of a quadratic equation are where . If solutions are imaginary. We assess the implementation on the following input data: Coefficient Value a +3.0 b -2.0 c -1.0/3.0 where the solutions are On the right you can find the implementation and the validation of the numerical solutions with respect to the exact solutions. // Define input data a = 3; b = -2; c = -1/3; // Compute delta Delta = b^2-4*a*c; // Compute solutions x1 = (-b+sqrt(Delta))/(2*a); x2 = (-b-sqrt(Delta))/(2*a); // Display the solutions disp(x1); disp(x2); 0.8047379 - 0.1380712 // 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) x1e = 0.8047379 x2e = - 0.1380712 diff_x1 = 0. diff_x2 = 0.
  • 12. Scilab as a Calculator www.openeering.com page 12/12 Step 19: Concluding remarks and References In this tutorial we have introduced to the user Scilab as a basic calculator, in order to make him/her comfortable with Scilab basic operations. 1. Scilab Web Page: www.scilab.org. 2. Openeering: www.openeering.com. Step 20: Software content To report a bug or suggest some improvement please contact Openeering team at the web site www.openeering.com. Thank you for your attention, Anna Bassi, Manolo Venturin ---------------------- SCILAB AS A CALCULATOR ---------------------- -------------- Main directory -------------- license.txt : the license file example_calculator.sce : examples in this tutorial