Sie sind auf Seite 1von 56

Equalis Community

Scilab Get Started Guide

8/10/2011 Company Confidential 2011 1


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 2


Chapter 1
Installation & Configuration

8/10/2011 Company Confidential 2011 3


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 4


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 Scilab
GNU/Linux 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 6


Installation for Mac

Recommended versions of Scilab for your Mac OS


(Latest Scilab version: 5.3.3)
OS Scilab
Snow Leopard (Mac OS X 10.6) 5.3.3

Lion (Mac OS X 10.7) Nightly build(*)


Leopard (Mac OS X 10.5) 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 7


Chapter 2
Getting Started with
Scilab Fundamentals

8/10/2011 Company Confidential 2011 8


Scilab Console

Variable
Browser Command
Editor
Window
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
List of Installed
of
Toolboxes
Toolboxes
Available

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

plzr:
plot2d pole-zero
plot

fchamp:
plot3d direction
field
8/10/2011 Company Confidential 2011 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 for integer .


Solve the above implicit ODE for .

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
8/10/2011 Company Confidential 2011 17
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 csv file


M = read_csv(“data_file.csv”)

Write a csv file


write_csv(Mnew,“new_data_file.csv”)

8/10/2011 Company Confidential 2011 22


Scilab’s Powerful Data Analysis
Toolboxes
• Statistics
• Spreadsheet
• Input/Output functions
• csv_readwrite
• NaN toolbox
• Stixbox
• Artificial Neural Network (ANN) toolbox
• Scilab JSON toolbox
• OPC Client
• Socket
• etc.

8/10/2011 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 – don’t 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). That’s it!

8/10/2011 Company Confidential 2011 24


Excel: Features Comparison/2

Matrix multiplication: Obtain B = A*X

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

Scilab
Type A*X. That’s 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 Matlab Toolbox Scilab Toolboxes
Signal Processing Signal Processing Signal Processing
Filter Design Signal Processing
Image Processing SIVP, IPD, SIP
Toolbox
Communications Communications OPC Client, Serial Port (under
development, source code available)
Communications HART toolbox, DDE Toolbox,
Blockset ScilabSerialLib toolbox, Socket
Compiling MATLAB Compiler Scilab 2 C
Spreadsheet Spreadsheet EXCEL xls nlink
MATLAB Builder EXCEL Scilab_XLL
Misc Database Toolbox Database Module + FuzzySQL
AeroSpace CelestLab

8/10/2011 Company Confidential 2011 29


Scilab has Equivalent Toolboxes to
Matlab/2
Application Matlab Toolbox Scilab Toolboxes
Numerical Matlab Scilab
Symbolic Math SciMax toolbox, Symbolic Computing
Statistics Statistic, Randlib, Stixbox
Simulation Simulink Xcos
Simulink Accelerator Code Generator
Control Systems Control System CACSD
Robust Control CACSD
System Identification CACSD
Optimization Optimization Optimization, Quapro, Fmincon
Neural Network ANN Toolbox
Parallel computing 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 Test and


acquisition Acquire Measurement
toolboxes Equipment
Create

Measure
Visualize Analyze
Experiments or
Iterate System to be
Create measured
Models
8/10/2011 Company Confidential 2011 48
Data Acquisition Toolboxes

Scilab together with toolboxes allows the communication between an


instrument and Scilab via specific connections.
Connection Toolbox
Serial Serial Communication Toolbox
GPIB Toolbox (with VISA)
TCP/IP Socket Toolbox Scilab + Toolboxes

GPIB GPIB Toolbox (with VISA)


USB GPIB Toolbox (with VISA) VISA

Serial TCP/IP GPIB, USB, Serial

Instrument Instrument Instrument

8/10/2011 Company Confidential 2011 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

Das könnte Ihnen auch gefallen