SlideShare a Scribd company logo
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

DENSITY OF ENERGY STATES
DENSITY OF ENERGY STATESDENSITY OF ENERGY STATES
DENSITY OF ENERGY STATES
Sathees Physics
 
Silicon Photonics for Data Centers and Other Applications 2016 - Report by Yo...
Silicon Photonics for Data Centers and Other Applications 2016 - Report by Yo...Silicon Photonics for Data Centers and Other Applications 2016 - Report by Yo...
Silicon Photonics for Data Centers and Other Applications 2016 - Report by Yo...
Yole Developpement
 
Beam profile
Beam profileBeam profile
Beam profile
Andrei Tsiboulia
 
Laser ppt.
Laser ppt.Laser ppt.
Laser ppt.
shivam5667
 
Chapter3 introduction to the quantum theory of solids
Chapter3 introduction to the quantum theory of solidsChapter3 introduction to the quantum theory of solids
Chapter3 introduction to the quantum theory of solids
K. M.
 
M2 point defects
M2 point defectsM2 point defects
M2 point defects
Anuradha Verma
 
Lagrangian formulation 1
Lagrangian formulation 1Lagrangian formulation 1
Lagrangian formulation 1
Dr. A. Vahid Hasmani
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
luyenkimnet
 
Pill Camera
Pill CameraPill Camera
Pill Camera
Aakanksh Nath
 
Metamaterial
MetamaterialMetamaterial
Metamaterial
Pusuluri Kiran
 
Solar Cell
Solar CellSolar Cell
Solar Cell
RAHULKUMAR4155
 
Ion beam lithography
Ion beam lithographyIon beam lithography
Ion beam lithography
Hoang Tien
 
Industrial Laser Applications
Industrial Laser ApplicationsIndustrial Laser Applications
Industrial Laser Applications
Soorej Thekkeyil
 
Perovskite
PerovskitePerovskite
Perovskite
Preeti Choudhary
 
Semiconductor Diodes and Circuits
Semiconductor Diodes and CircuitsSemiconductor Diodes and Circuits
Semiconductor Diodes and Circuits
Darwin Nesakumar
 
7 band structure
7 band structure7 band structure
7 band structure
Olbira Dufera
 
Night Vision Technology
Night Vision TechnologyNight Vision Technology
Night Vision Technology
Manoj Kumar
 
Chapter 3 wave_optics
Chapter 3 wave_opticsChapter 3 wave_optics
Chapter 3 wave_optics
Gabriel O'Brien
 
Deep Learning through Pytorch Exercises
Deep Learning through Pytorch ExercisesDeep Learning through Pytorch Exercises
Deep Learning through Pytorch Exercises
aiaioo
 
Hall effect
Hall effect Hall effect
Hall effect
Harsh Shukla
 

What's hot (20)

DENSITY OF ENERGY STATES
DENSITY OF ENERGY STATESDENSITY OF ENERGY STATES
DENSITY OF ENERGY STATES
 
Silicon Photonics for Data Centers and Other Applications 2016 - Report by Yo...
Silicon Photonics for Data Centers and Other Applications 2016 - Report by Yo...Silicon Photonics for Data Centers and Other Applications 2016 - Report by Yo...
Silicon Photonics for Data Centers and Other Applications 2016 - Report by Yo...
 
Beam profile
Beam profileBeam profile
Beam profile
 
Laser ppt.
Laser ppt.Laser ppt.
Laser ppt.
 
Chapter3 introduction to the quantum theory of solids
Chapter3 introduction to the quantum theory of solidsChapter3 introduction to the quantum theory of solids
Chapter3 introduction to the quantum theory of solids
 
M2 point defects
M2 point defectsM2 point defects
M2 point defects
 
Lagrangian formulation 1
Lagrangian formulation 1Lagrangian formulation 1
Lagrangian formulation 1
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Pill Camera
Pill CameraPill Camera
Pill Camera
 
Metamaterial
MetamaterialMetamaterial
Metamaterial
 
Solar Cell
Solar CellSolar Cell
Solar Cell
 
Ion beam lithography
Ion beam lithographyIon beam lithography
Ion beam lithography
 
Industrial Laser Applications
Industrial Laser ApplicationsIndustrial Laser Applications
Industrial Laser Applications
 
Perovskite
PerovskitePerovskite
Perovskite
 
Semiconductor Diodes and Circuits
Semiconductor Diodes and CircuitsSemiconductor Diodes and Circuits
Semiconductor Diodes and Circuits
 
7 band structure
7 band structure7 band structure
7 band structure
 
Night Vision Technology
Night Vision TechnologyNight Vision Technology
Night Vision Technology
 
Chapter 3 wave_optics
Chapter 3 wave_opticsChapter 3 wave_optics
Chapter 3 wave_optics
 
Deep Learning through Pytorch Exercises
Deep Learning through Pytorch ExercisesDeep Learning through Pytorch Exercises
Deep Learning through Pytorch Exercises
 
Hall effect
Hall effect Hall effect
Hall effect
 

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 conditioning
Scilab
 
First steps with Scilab
First steps with ScilabFirst steps with Scilab
First steps with Scilab
Scilab
 
Aeraulic toolbox for Xcos
Aeraulic toolbox for XcosAeraulic toolbox for Xcos
Aeraulic toolbox for Xcos
Scilab
 
Data mining
Data miningData mining
Data mining
Scilab
 
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
Scilab
 
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
Scilab
 
Introduction to Control systems in scilab
Introduction to Control systems in scilabIntroduction to Control systems in scilab
Introduction to Control systems in scilab
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...
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 equations
Scilab
 
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
Scilab
 
Programa para calcular valores de resistencias
Programa para calcular valores de resistenciasPrograma para calcular valores de resistencias
Programa para calcular valores de resistencias
Ulises 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-Part1
Elaf 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_18012013
Kurmendra Singh
 
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
amanabr
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
Dushmanta Nath
 
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
MOHAMMAD SAYDUL ALAM
 
Basic of octave matlab programming language
Basic of octave matlab programming languageBasic of octave matlab programming language
Basic of octave matlab programming language
Aulia Khalqillah
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
sunny khan
 
Basics of c++
Basics of c++ Basics of c++
Basics of c++
Gunjan Mathur
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
Sabi995708
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
Kathirvel Ayyaswamy
 
03. Week 03.pptx
03. Week 03.pptx03. Week 03.pptx
03. Week 03.pptx
Vinc2ntCabrera
 
[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
Muhammad Hammad Waseem
 
Simplex algorithm
Simplex algorithmSimplex algorithm
Simplex algorithm
Khwaja Bilal Hassan
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
rohassanie
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
Mohammed Saleh
 
Perl
PerlPerl
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
bilawalali74
 
Simplex Algorithm
Simplex AlgorithmSimplex Algorithm
Simplex Algorithm
Aizaz 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
 
Using matlab simulink
Using matlab simulinkUsing matlab simulink
Using matlab simulink
Marilyn Barragán Castañeda
 

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 Design
Scilab
 
Electric motor optimization
Electric motor optimizationElectric motor optimization
Electric motor optimization
Scilab
 
Asteroidlanding - Scilab conference 2019 Keynote
Asteroidlanding - Scilab conference 2019 KeynoteAsteroidlanding - Scilab conference 2019 Keynote
Asteroidlanding - Scilab conference 2019 Keynote
Scilab
 
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 modelling
Scilab
 
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 XCos
Scilab
 
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
 
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
 
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
Scilab
 
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
 
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 2018
Scilab
 
Qualcomm @ Scilab Conference 2018
Qualcomm @ Scilab Conference 2018Qualcomm @ Scilab Conference 2018
Qualcomm @ Scilab Conference 2018
Scilab
 
Sanofi @ Scilab Conference 2018
Sanofi @ Scilab Conference 2018Sanofi @ Scilab Conference 2018
Sanofi @ Scilab Conference 2018
Scilab
 
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
Scilab
 
DLR @ Scilab Conference 2018
DLR @ Scilab Conference 2018DLR @ Scilab Conference 2018
DLR @ Scilab Conference 2018
Scilab
 
Fraunhofer IIS @ Scilab Conference 2018
Fraunhofer IIS @ Scilab Conference 2018Fraunhofer IIS @ Scilab Conference 2018
Fraunhofer IIS @ Scilab Conference 2018
Scilab
 
Arcelormittal @ Scilab Conference 2018
Arcelormittal @ Scilab Conference 2018Arcelormittal @ Scilab Conference 2018
Arcelormittal @ Scilab Conference 2018
Scilab
 

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

ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
zwunae
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
Self-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptxSelf-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptx
iemerc2024
 

Recently uploaded (20)

ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
Self-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptxSelf-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptx
 

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