You are on page 1of 56

Equalis Community Scilab Get Started Guide

8/10/2011

Company Confidential 2011

Table of Contents
Chapter 1: Installation & Configuration Chapter 2: Getting Started with Scilab Fundamentals Chapter 3: Migrating Data, Datasets and Files into Scilab Chapter 4: Applications Introduction & Review

8/10/2011

Company Confidential 2011

Chapter 1 Installation & Configuration

8/10/2011

Company Confidential 2011

General Information
Download Scilab from Equalis website www.equalis.com Comprehensive GUI will guide you through the installation process For Windows and Mac For Linux, please see slide 4 for more details
Which version of Scilab works for your OS? Review on next slides

8/10/2011

Company Confidential 2011

Installation for Windows


Recommended versions of Scilab for your Windows OS (Latest Scilab version: 5.3.3)
OS Scilab Windows 7, Vista, XP* 32 bits 5.3.3 (32-bit) 64 bits 5.3.3 (64-bit) Windows 2000 5.2.1 Older version of Windows Version 4
(*) If installing Scilab v.5.3.x results in the error "CPU SSE2 instructions are required for Scilab to run correctly, your machine is missing the SSE2 chip instructions. From Scilab version 5.3.0, CPU SSE2 instructions are required for Scilab to run correctly. In order to install v.5.3.x, your processor needs to be upgraded to the one that has the SSE2 instruction set. Or you can download Scilab v.5.2.2 on your current machine.
8/10/2011 Company Confidential 2011 5

Installation for Linux


Recommended versions of Scilab for your Linux OS (Latest Scilab version: 5.3.3)
OS GNU/Linux Scilab 5.3.3 (32-bit) 5.3.3 (64-bit)

Put Scilab folder in the directory where you want to install Scilab (call it <scilab-path>) Launch Scilab with the following commands
[$SHELL] cd <scilab-path>/scilab-5.3.3 [$SHELL] ./bin/scilab

8/10/2011

Company Confidential 2011

Installation for Mac


Recommended versions of Scilab for your Mac OS (Latest Scilab version: 5.3.3)
OS Snow Leopard (Mac OS X 10.6) Lion (Mac OS X 10.7) Leopard (Mac OS X 10.5) Scilab 5.3.3 Nightly build(*) 5.2.2

(*) Please refer to a workaround given in http://bugzilla.scilab.org/show_bug.cgi?id=9766 Note: Since v.5.3, only 64-bit OS is supported

8/10/2011

Company Confidential 2011

Chapter 2 Getting Started with Scilab Fundamentals

8/10/2011

Company Confidential 2011

Scilab Console

Variable Browser

Command Window

Editor Window (SciNotes)

History Browser

You can dock windows as shown above by dragging one window to another.
8/10/2011 Company Confidential 2011 9

Basic Functions
Use matrices for input/output

Solve Ax = B

Construct a 3 by 3 random matrix and a 3 by 1 random vector

Find eigenvalues of matrix A

8/10/2011

Company Confidential 2011

10

ATOMS
You can download and install toolboxes from ATOMS.

Click

Categories of Toolboxes Available

List of Installed Toolboxes

8/10/2011

Company Confidential 2011

11

ATOMS Installing a Toolbox

Select a toolbox you want to install

Click to install

8/10/2011

Company Confidential 2011

12

Graphing 2D, 3D
Scilab has a huge assortment of graphic capabilities
Large 2D and 3D plotting library 2D graphics Special control systems, signal processing graphs Matlab plotting emulation toolbox

8/10/2011

Company Confidential 2011

13

Graphing Examples

plot2d

plzr: pole-zero plot

plot3d
8/10/2011 Company Confidential 2011

fchamp: direction field


14

ODE / DAE Systems


Scilab toolboxes supporting these capabilities
Differential equations toolbox CACSD (Computer Aided Control Systems Design) toolbox Extensive toolbox covering many control functions and plots Well integrated with Xcos simulation tool

8/10/2011

Company Confidential 2011

15

ODE / DAE Systems Example

Initial value of the derivative is Solve the above implicit ODE for

for integer

8/10/2011

Company Confidential 2011

16

Optimization
Scilab toolboxes supporting these capabilities
Optimization and simulation toolbox (in baseline Scilab) Quapro Unconstrained Optimization SciCOBYLA - derivative free non linear constrained optimization method Markov Decision Processes (MDP) toolbox Optkelley iterative optimization algorithms from a book by C. T. Kelley A Toolbox for Unconstrained Global Optimization of Polynomial functions And many others
Company Confidential 2011 17

8/10/2011

Optimization Example
Solve the linear programming problem

(2.67, 0.67)

8/10/2011

Company Confidential 2011

18

Getting Help
The following resources are available for Community Edition support;
Equalis Community site
Forum Scilab Tips

Scilab built-in features


Help browser Demonstrations

For more complete support, including email, phone, Chat, as well as access to the exclusive Equalis SOS portal, providing complete on-line searchable documentation, Video Tutorials, Tech Tips, etc, please review our Equalis Pro and Pro Plus programs. For advanced premium features and applications please also review our Equalis Pro and Pro Plus programs
8/10/2011 Company Confidential 2011 19

Chapter 3 Migrating Data, Datasets and Files into Scilab


8/10/2011 Company Confidential 2011 20

Datasets Supported
Data import/export using simple commands Data type
xls txt csv xml binary mat etc.

Data size
Up to 2.1 GB of memory = a 16,384 x 16,384 dense matrix of doubles Can use a HUGE dataset!

Can perform various matrix-based syntaxes to the entire data set simple and fast computation
8/10/2011 Company Confidential 2011 21

Importing/Exporting Data
csv file Read in Scilab
M = read_csv(data_file.csv)

csv file

Write a csv file


write_csv(Mnew,new_data_file.csv)

8/10/2011

Company Confidential 2011

22

Scilabs Powerful Data Analysis Toolboxes



8/10/2011

Statistics Spreadsheet Input/Output functions csv_readwrite NaN toolbox Stixbox Artificial Neural Network (ANN) toolbox Scilab JSON toolbox OPC Client Socket etc.
Company Confidential 2011 23

Excel: Features Comparison/1


Creating a big matrix of random numbers Excel
Method 1: Type =rand() in one cell, and drag the corner for repeat process Problem dont want to do this for a big matrix Method 2: Write a macro Problem too much trouble for a simple task

Scilab
Use the function rand(size of matrix). Thats it!

8/10/2011

Company Confidential 2011

24

Excel: Features Comparison/2


Matrix multiplication: Obtain B = A*X Excel
1. 2. 3. Select the cells to put B Type =MMULT(range of A, range of X) Press Ctrl+Shift+Enter

Scilab
Type A*X. Thats it!

8/10/2011

Company Confidential 2011

25

Excel: Features Comparison/3


Inverting a matrix Excel
Only up to 51-by-51 matrices Only square matrices

Scilab
Can invert large matrices (square or non-square) - For square matrices: inv(A) - For non-square matrices: pinv(A) (pseudoinverse)

8/10/2011

Company Confidential 2011

26

Excel: Features Comparison/4


G: a column vector of 100 students exam scores Obtain
mean median maximum minimum histogram

Note: The vector G is defined beforehand.

8/10/2011

Company Confidential 2011

27

Scilab Provides Equivalent Regression Analysis to Excel


Given a set of data, obtain the best fitting curve
Minimize the cost function given by the norm of the difference between the data and model in the least squares sense

Model 1 (blue): f(t) = a*sin(t) + b*t R=0.7501881 Model 2 (green): f(t) =a+b*t+c*t 2+d*t 3+e*t 4+f*t 5 R=0.7160991
8/10/2011 Company Confidential 2011 28

Scilab has Equivalent Toolboxes to Matlab/1


Application Signal Processing Matlab Toolbox Signal Processing Filter Design Image Processing Toolbox Scilab Toolboxes Signal Processing Signal Processing SIVP, IPD, SIP

Communications

Communications Communications Blockset

OPC Client, Serial Port (under development, source code available) HART toolbox, DDE Toolbox, ScilabSerialLib toolbox, Socket
Scilab 2 C xls nlink Scilab_XLL

Compiling Spreadsheet

MATLAB Compiler Spreadsheet EXCEL MATLAB Builder EXCEL

Misc

Database Toolbox AeroSpace

Database Module + FuzzySQL CelestLab


29

8/10/2011

Company Confidential 2011

Scilab has Equivalent Toolboxes to Matlab/2


Application Numerical Matlab Toolbox Matlab Symbolic Math Statistics Scilab Toolboxes Scilab SciMax toolbox, Symbolic Computing Statistic, Randlib, Stixbox

Simulation

Simulink Simulink Accelerator

Xcos Code Generator


CACSD CACSD CACSD Optimization, Quapro, Fmincon

Control Systems

Control System Robust Control System Identification

Optimization

Optimization

Neural Network Parallel computing

ANN Toolbox PMV parallel Toolbox

8/10/2011

Company Confidential 2011

30

Matlab to Scilab Code Translation


Semi-automatic translation Very similar syntaxes No major structure changes There are some corner cases - Content oriented - GUIs - etc.

Equalis can help with any corner cases Also Equalis Pro and Pro Plus support programs can help automate your processes through script development
8/10/2011 Company Confidential 2011 31

Code Translation Example


Truncation effects of a time-domain signal
Reference: Digital Signal Processing Demonstrations https://engineering.purdue.edu/VISE/ee438/demos/Demos.html

No structure change Minor changes: comments % --> // clear all --> clear close all --> xdel(winsid()) pi --> %pi figure() --> scf() fft(x) --> fft(x, -1), ifft(x) --> fft(x, 1) Identical outputs

8/10/2011

Company Confidential 2011

32

Matlab to Scilab Translation/1


Matlab Scilab

8/10/2011

Company Confidential 2011

33

Matlab to Scilab Translation/2

8/10/2011

Company Confidential 2011

34

Matlab to Scilab Translation/3

8/10/2011

Company Confidential 2011

35

Matlab to Scilab Translation Results/1

Figure 1: cosine wave with frequency=2pi*(20/7) rad/sample and time=[1:128] sec


8/10/2011 Company Confidential 2011 36

Matlab to Scilab Translation Results/2

Figure 2: FFT of cosine wave


8/10/2011 Company Confidential 2011 37

Matlab to Scilab Translation Result/3

Figure 3: Truncated cosine wave


8/10/2011 Company Confidential 2011 38

Matlab to Scilab Translation Results/4

Figure 4: FFT of truncated cosine wave


8/10/2011 Company Confidential 2011 39

Matlab to Scilab Translation Results/5

Figure 5: FFT of both original and truncated cosine waves


8/10/2011 Company Confidential 2011 40

Chapter 4 Applications Introduction & Review


8/10/2011 Company Confidential 2011 41

Scilab Advanced Modules

Advanced Signal Processing

Control Systems

Algorithm Development

Test & Measurement

Embedded Systems

Mechatronic Systems

8/10/2011

Company Confidential 2011

42

Advanced Signal Processing Application


Measures, filters and compresses continuous real-world analog signals

Includes sound, images, sensor data, bio-data, radio, telecommunication Processes include: filtering, smoothing, pattern recognition, prediction, correction, digitization

8/10/2011

Company Confidential 2011

43

Signal Processing Toolboxes


Scilab provides the integrated toolboxes for signal processing such as: Time Frequency toolbox Scilab Wavelet toolbox Linear System Inversion toolbox EMD Empirical Mode Decomposition toolbox Minphase IIR filter IPD Image Processing and Design toolbox SIVP Image and Video Processing toolbox Microwave toolbox Sound file toolbox ANN Artificial neural network toolbox Signal Processing in Xcos And many related toolboxes
8/10/2011 Company Confidential 2011 44

Control Systems Simulation Application


Deals with a device or set of devices to manage, control, direct or regulate the behavior of other devices or systems

Includes: Linear Controls, Non-Linear Controls, Digital Controls, Optimal Controls, Adaptive Controls, Robust Controls Encompasses: Electronics, mechanical systems, thermo-hydraulic, chemical engineering, financial and biological systems
8/10/2011 Company Confidential 2011 45

Control Systems Toolboxes


Scilab provides the integrated toolboxes for control systems such as:

CACSD Computer Aided Control Systems Design ANN Neural Networks toolbox Celeste Lab Aerospace toolbox (modeling and control) DACE Design and Analysis of Computer Experiments Linear Time Invariant Systems - Identification Toolbox Linear Model Neural Network Lolimont toolbox Linear System Inversion toolbox
Control Systems in Xcos And many related toolboxes in statistics, DiffEqs, and Linear Algebra
8/10/2011 Company Confidential 2011 46

CACSD Toolbox
Continuous Time Systems

Discrete Time Systems


Non-Linear Optimal
LQG

Robust
H2/H-Infinity Riccati

8/10/2011

Company Confidential 2011

47

Test and Measurement Application

Scilab + Data acquisition toolboxes

Acquire

Test and Measurement Equipment

Create

Visualize

Analyze
Iterate

Create Models
8/10/2011 Company Confidential 2011

Experiments or System to be measured

Measure

48

Data Acquisition Toolboxes


Scilab together with toolboxes allows the communication between an instrument and Scilab via specific connections.
Connection Serial TCP/IP GPIB USB Toolbox Serial Communication Toolbox GPIB Toolbox (with VISA) Socket Toolbox GPIB Toolbox (with VISA) GPIB Toolbox (with VISA)
Serial TCP/IP
VISA Scilab + Toolboxes

GPIB, USB, Serial

Instrument
8/10/2011 Company Confidential 2011

Instrument

Instrument
49

GUI Design
Scilab has GUIs
Baseline Scilab capabilities Specialized toolboxes for GUI building Ability to interface with external GUI via APIs Ability to interface with external code All major GUI elements supported
List boxes, Text boxes, menus, frames, popup menus Sliders, radio buttons, checkboxes, pushbuttons

8/10/2011

Company Confidential 2011

50

GUI Example

8/10/2011

Company Confidential 2011

51

Simulation
Xcos: Main toolbox for simulation similar to Simulink or LabView
Allows the user to build a wide assortment of models and perform simulations on those models Very easy to learn and implement Good integration with Scilab environment

8/10/2011

Company Confidential 2011

52

Signal Processing with Xcos


Add noise to sinusoid signal, and de-noise the signal
Uniform distribution with min = -0.5 and max = 0.5

Original signal

Noisy signal

De-noised signal

Transfer function: 1/(1+s+s 2)


8/10/2011

Company Confidential 2011

53

Water Tank Design Using Xcos


Demo: Xcos model of a water tank water level monitoring system

Super-block

8/10/2011

Company Confidential 2011

54

Further Information
Ask questions in our Community Forum Read Scilab Tips to learn more about Scilab For more complete support and our advanced premium features and applications, please also review our Equalis Pro and Pro Plus programs

8/10/2011

Company Confidential 2011

55

Email: sales@equalis.com
Tel: 408-912-1686

www.equalis.com
8/10/2011 Company Confidential 2011 56

You might also like