# Scilab/C4/Digital-Signal-Processing/English

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 of 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.

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 d into bracket within invertes comma gnn then comma t comma x and press Enter on your keyboard.

Display the plot generated This is discret 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 into braccket one comma two comma three comma

four

Then type h equals to into 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 into braccket one comma two comma three comma four

Then

Type inside 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

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:

Bracket x equals to dft into 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= [1,2,3,4] x equals to into braccket one comma two comma three comma four

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

Press Enter and you can see the output as

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 into bracket ten comma minus two plus two into percentage i comma minus two comma minus two plus minus two into percentage i.

and Press Enter

Type x = fft(y,1) x equals to fft into 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 into braccket one comma two comma three comma fourand press Enter

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

Type Are x one x two equals to corr into 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 sampling 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 me summarise.
Slide 14 In this tutorial we learnt
Display Summary slide 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 the sampling

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

/What is a Spoken Tutorial

It summarises the Spoken Tutorial

project

If you do not have good

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

For more details, contact

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

available at:

/NMEICT-Intro

Disaplay “Contributors” slide This script has been contributed

by Manas and this is Anuradha

signing off

Thank you for watching