Beruflich Dokumente
Kultur Dokumente
Dr. C. SREEKUMAR,
Professor ,EEE Department,
GCE Kannur
Outline
SCILAB Basics
SCILAB Scripting
SCILAB plotting
XCOS Environment
Dr. C. Sreekumar 1
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB - A POWERFUL COMPUTING TOOL
Dr. C. Sreekumar 2
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB -Features
SCILAB -Features
Dr. C. Sreekumar 3
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB -Features
Dr. C. Sreekumar 4
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB Environment
SCILAB Environment
Dr. C. Sreekumar 5
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB Environment- Contd..
Basic Operations
Basic Conventions
Separate the elements of a row with blanks or commas
Use a semicolon ; to indicate the end of each row.
Surround the entire list of elements with square brackets [ ]
Dr. C. Sreekumar 6
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Basic Operations...Contd
16 3 2 13
5 10 11 8
A=
9 6 7 12
4 15 14 1
To suppress output, end the line with a semicolon
»a=3
a=3
»a=3;
Variable names ⇒ Case Sensitive
» B= [1,6,3,2;5,1,0,8;9,6,7,2;4,15,1,4];
If variable name is not specified, the default name is ’ans’
1 2 3
A1 = 2 1 3
3 1 2
1 2 3 3 6 9
2 1 3 6 3 9
3 1 2 9 3 6
A2 =
−1 −2 −3 2 4 6
−2 −1 −3 4 2 6
−3 −1 −2 6 2 4
Dr. C. Sreekumar 7
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB -Basic Commands
Dr. C. Sreekumar 8
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB -Basic Commands-Contd...
Dr. C. Sreekumar 9
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB Commands to Save and retrieve matrices
Dr. C. Sreekumar 10
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB-Basic Commands- Contd..
The
⎛ ⎞back slash operator also gives the same result
x
⎝y ⎠ = A\b
z
Dr. C. Sreekumar 11
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
User defined SCILAB- *.sce file
SCILAB commands can be put together in a *.sce file,
which can be used many times. Can be modified later
dy (x−y )
dx = 2
Dr. C. Sreekumar 12
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Numerical solution of differential equation
Plotting Curves
Dr. C. Sreekumar 13
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Can change the line color, marker style, and line style by
adding a string argument
» plot(x,y,’k.-’); ⇒ k indicates color, . indicates point marker, -
indicates line style
Try → » help plot ⇒ practice the various options
A second plot command normally overwrites the first
To draw 2 curves in the same graph
» plot(x,y,’r’,x,2*y,’g’);
» legend("speed","scaled speed");
» xlabel("Time");
» ylabel("speed");
» title("PLOT ");
Dr. C. Sreekumar 14
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Dr. C. Sreekumar 15
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Plotting - A Code to try
Heart
2.0
1.5
1.0
0.5
0.0
-0.5
-1.0
-1.5
-2.0
-1.0 -0.8 -0.6 -0.4 -0.2 0.0 0.2 0.4 0.6 0.8 1.0
Dr. C. Sreekumar 16
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Simple 3d plot
A simple 3d plot
15
10
Function 0
−5
−10
−15
0 0
1 1
2 2
3 3
4 4
Time 5 5 Time
6
Stylish 3d plots
1 1
Z Z
0 0
−1 −1
−1 −1 −1
−0.5 −0.5
0 0 X 0 0 X
Y Y
0.5 0.5
1 1 1 1
1 1
Z Z
0 0
−1 −1
−1 −1 −1
−0.5 −0.5
0 0 X 0 0 X
Y Y
0.5 0.5
1 1 1 1
Dr. C. Sreekumar 17
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Animated 3d plots
10
1
1
0 0.5
1 0
0.5 −0.5
0 −1
−0.5
−1
Contour Plots
2.5 0.181
0.271
0.542
0.6320.3610.0903
2 0.813
0.903
0.722
0.451
0.3610.0903
0.903 0.542
0.813 0.181 0.1810.542
0.361
0.632
0.722 0.271
0.451 0.0903
0.271
0.451
0.632
1.5
0.5
−0.5 0.181
0.0903
0.271
0.542
−1 0.361
0.632
0.813
0.722
0.903
0.722
0.632
0.813 0.451
0.271
0.361
0.542 0.0903 0.451 0.451
0.271 0.632
−1.5 0.903 0.181 0.181
0.361
0.0903 0.542
−2
−2.5
−3
−4 −3 −2 −1 0 1 2 3 4
Dr. C. Sreekumar 18
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Surface Plots
0.8
0.6
0.4
0.2
1 −0.2
0.5 −0.4
1
0 0.5
Y
0
−0.5 X
−0.5
−1 −1
Surface Plots
Dr. C. Sreekumar 19
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Subplots in SCILAB
Dr. C. Sreekumar 20
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Plots of user defined functions
Dr. C. Sreekumargraphics 21
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Plots -functions in separate files Saving Figures
1 400
1 200
mesquare_and_cube
1 000
800
600
400
200
0
0 1 2 3 4 5 6 7 8 9 10 11 12
ME
Dr. C. Sreekumar 22
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Plotting functions of two variables
Dr. C. Sreekumar 23
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Histograms
Pie charts
Dr. C. Sreekumar 24
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Bar charts
SCILAB-File Writing
Dr. C. Sreekumar 25
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
SCILAB-File Reading
!
!
"#
$
"#$
% &'' $%&
' #
()
*()
)(*
)
)'
))
)*)()*+,
"$
-$
#.""
$"
/) )0 1)2)))1)1)1)%11113
-4$( $((
#$""("(
$
$
$
5#
-
4$ $
Dr. C. Sreekumar 26
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
De ning system in TF or SS Form
Dr. C. Sreekumar 27
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Bode Plots 40
20
Magnitude (dB)
0
−20
−40
−60
−3 −2 −1 0 1 2 3
10 10 10 10 10 10 10
Frequency (Hz)
−20
−40
Phase (degree)
−60
−80
−100
−120
−3 −2 −1 0 1 2 3
10 10 10 10 10 10 10
Frequency (Hz)
gainplot(sys)-magnitude plot
show-margins(sys)- phaseplot(sys)-frequency
display gain and phase plot
phase
margin and crossover
frequencies
g-margin(sys)-
p-margin(sys)
Dr. C. Sreekumar 28
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Nyquist Plots
Nyquist plot
30
−0.0727 −0.0476
25
−0.116
20
15
−0.217 −0.0152
10
1e+03
0 0.001
−5
−10
0.217 0.0152
−15
−20 0.116
−30
−10 −5 0 5 10 15 20 25 30 35 40 45 50 55 60
Dr. C. Sreekumar 29
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Plotting - A Code to try
Heart
4
90
120 60
3
2 150 30
0 0
0.5
-1 1
1.5
-2 210 2 330
2.5
-3 3
240 300
270
-4
-4 -3 -2 -1 0 1 2 3 4
Signal Sampling
Cont inuous signal
!! 1.0
0.4
Am plit ude
0.2
$+)
$,"
, 0.0
Dr. C. Sreekumar 30
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
xcos GUI
xcos GUI
Dr. C. Sreekumar 31
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
Simulation using Xcos
1.5
y
0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t
1.5 1.5
1 1
0.5 0.5
0 0
y
−0.5 −0.5
−1 −1
−1.5 −1.5
Dr. C. Sreekumar0 2 4 6 8 10 12 14
t
16 18 20 22 24 26 28 30 0 2 4 6 8 10 12 14
t
16 18 20 22 24 26 28 30
32
FDP on Electronic Design Tools : Computing with Scilab 12/12/2017
THANK YOU
Dr. C. Sreekumar 33