Scilab/C4/Digital-Signal-Processing/English

From Script | Spoken-Tutorial
Revision as of 14:48, 20 May 2015 by Gaurav (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of script: Signal processing Using Scilab

Author: Manas

Keywords: Video tutorial, Signal


Visual Cue
Narration
Slide 1 Dear Friends,

Welcome to the spoken tutorial on “Signal Processing using Scilab

Slide 2 -Learning Objective Slide In this tutorial, using Scilab, I will show you how to


Generate different kinds of signals , and


Perform different operations to analyse signals.

Slide 3-System Requirement slide To record this tutorial, I am using Ubuntu 11.04 as the operating system with Scilab 5.3.3 version
Slide 4- Prerequisite slide Before practicing this tutorial, a learner should have a basic knowledge of Scilab.

To know the basics of Scilab, please refer to the series of basic level spoken tutorials in Scilab....


....which is available on our website www.spoken-tutorial.org

Slide 7 In this tutorial, I will describe about 3 basic Signals.
  • Plotting continuous and discrete sine wave.
  • Plotting step function.
  • Plotting ramp function.

Let me start with “Plotting continuous and discrete sine wave”

Switch to the Scilab Console Window and type:

t = 0:0.1:2*%pi;

x = sin(t);

plot2d(t,x)

Let us switch to the Scilab Console Window.

Here type:


t equal to zero colon zero point one colon two multiplied by precentage pi semicolon.

x equal to sin of t semicolon plot 2D into bracket t comma x


and press Enter key on your keyboard.

Display the plot generated This is a continous sine wave



On the console window type:

plot2d3('gnn',t,x)


Let us discuss the discrete sine wave.


On the console window type: plot two d3 within bracket invertes comma gnn comma t comma x and press Enter.



Display the plot generated This is discrete sine wave.
Switch to Slide 7: and display 2nd and 3rd point of Slide 7 Let us now discuss about Plotting step function and

plotting ramp function.

Open scilab editor.

Open the file signal.sce

I have already written the code to generate step and ramp signal in the file called signals.sce.


Let us open this file signal.sce using scilab editor.


Let us execute this code.


Click on the “Execute” button in the Menu bar



Display the plot generated Step and Ramp signal is displayed in this plot.
Slide 8 Now let us learn how to perform different operations to analyse signals.


Let us see how to perform Convolution between two signals.

Swtich to Scilab console and type: x=[1,2 ,3,4]

Then type:

h=[1,1,1]

and then type


Type: convol(x,h) and press Enter


Let us switch to the Scilab Console window and type

x equals to within square braccket one comma two comma three comma four



Then type h equals to within square bracket one comma one comma one


Now let us apply the convoltion by typing convol opening bracket x comma h closing bracket


and press Enter on your keyboard.



Display the output generated An output can be seen here.
Now let us learn Discrete fourier transform for a discrete sequence by using the inbuilt command dft().
On the Scilab console window, type: x=[1,2,3,4]


Type: [xf]=dft(x,-1);

On the console window here type x equals to within square bracket one comma two comma three comma four


Then


Type within square bracket xf equals to dft into bracket x comma minus 1


Where x is the input vector


and flag value is -1 for DFT.


Let us press Enter



Display the output:


10.

- 2. + 2.i

- 2. - 9.797D-16i

- 2. - 2.i

The output appears as this


10.

- 2. + 2.i

- 2. - 9.797D-16i

- 2. - 2.i

Now I will show you how to calculate inverse discrete fourier transform. This can be done by using the same inbuilt command dft().
On the Scilab console window:[x]=dft(xf,1) On the Scilab console window type:

squareBracket x equals to dft within bracket xf comma 1


Here the flag value is 1 for idft.

Display the output: 1.

2. + 5.551D-17i

3. - 1.225D-16i

4. - 5.551D-16i

This is the output.

1.

2. + 5.551D-17i

3. - 1.225D-16i

4. - 5.551D-16i



Let us calculate discrete fourier transform using fft()
Type: x= [1,2,3,4] and press Enter

Type:y = fft(x,-1)


Display the output:

10. - 2. + 2.i - 2. - 2. - 2.i

On the console window, type x= square [1,2,3,4] x equals to square bracket one comma two comma three comma four

Press Enter and type y = fft(x,-1) y equals to fft within bracket x comma minus one

Press Enter and you can see the output as these:-


10. - 2. + 2.i - 2. - 2. - 2.i

On the Scilab Console window type: y=[10,-2+2*%i,-2,-2-2*%i] and press Enter


Type: x = fft(y,1)


and Press Enter


Let us now see how to calculate inverse discrete fourier transform by using fft().


On the Scilab console window type

y equals to within square bracket ten comma minus two plus two into percentage i comma minus two comma minus two minus two into percentage i.


and Press Enter


Type x = fft(y,1) x equals to fft within bracket y comma 1


and Press Enter



Display the output:

x =1. 2. 3. 4.

The output will be displayed as

x =1. 2. 3. 4.

Let us now find out the correlation between two vectors.
Switch to the Scilab console window


Type: x1=[1,2,3,4] and Press Enter


Type: x2=[1,3,1,5] and press Enter


Type Rx1x2 = corr(x1,x2,4)


The output will be displayed as

Rx1x2=1.25 0.3125 0.25 - 0.9375

To do this on the Scilab console window,


Type x one equals to within square bracket one comma two comma three comma fourand press Enter


Type x2 equals to within square braccket one comma three comma one comma five and press Enter


Type R x one x two equals to corr within bracket x one comma x two comma four and press Enter


The output will be displayed as

Rx1x2=1.25 0.3125 0.25 - 0.9375

Let us learn how to sample the given signal
Open sampling.sce


Click on “Execute” button


Display the output.

Let me open sampling.sce where

I have already written the code in sampling.sce


Here click on the “Execute”button.


A plot is displayed.



Let us summarise.
Slide 14 In this tutorial we have learnt
Display Summary slide How to Plot sine, step and ramp signal.


To perform Linear convolution by convol().


To perform DFT and IDFT by dft().


To perform FFT by fft().


To find out the Correlation by corr().


To do sampling

Display “About the Spoken Tutorial Project” Slide Watch the video available at


this URL http://spoken-tutorial.org


/What is a Spoken Tutorial


It summarises the Spoken Tutorial


project


If you do not have good


bandwidth, you can also download


and watch it



Display “ Spoken Tutorial Workshops” slide The Spoken Tutorial Project Team


Conducts workshops using spoken


tutorials


Gives certificates to those who


pass an online test


Please contact us


contact@spoken-tutorial.org



Display “Acknowledgment”

slide

Spoken Tutorial Project is a part


of the Talk to a Teacher project


It is supported by the National


Mission on Education through


ICT, MHRD, Government of India


More information on the same is


available at:


http://spoken-tutorial.org


/NMEICT-Intro



Disaplay “Contributors” slide This script has been contributed


by Manas and this is Sheetal Prabhu


signing off


Thank you for watching



Contributors and Content Editors

Gaurav, Lavitha Pereira, Nancyvarkey