R18 B.Tech. ECE Syllabus JNTU HYDERABAD
ECGO4PC: DIGITAL SIGNAL PROCESSING LAB
B.Tech. Il Year II Semester Ltepe
00 3 15
‘The Programs shall be implemented in Software (Using MATLAB / Lab View / C Programming!
Equivalent) and Hardware (Using TI Analog Devices / Motorola / Equivalent DSP processors)
Note: - Minimum of 12 experiments has to be conducted.
List of Experiments:
41, Generation of Sinusoidal Wavefom / Signal based on Recursive Difference Equations
_2e Histogram of White Gaussian Noise and Uniformly Distributed Noise.
To find DFT / IDFT of given DT Signal
To find Frequency Response of a given System given in Transfer Function! Differential equation
form,
§) Obtain Fourier series coefficients by formula and using FET and compare for half sine wave,
&. Implementation of FFT of given Sequence
7.
8
Determination of Power Spectrum of a given Signal(s)
Implementation of LP FIR Filter for a given SequencelSignal.
9. Implementation of HP IIR Filler for a given SequencelSignal
10. Generation of Narrow Band Signal through Fitering
11, Generation of DTMF Signals
42. Implementation of Decimation Process
'S3. Implementation of interpolation Process
414, Implementation of iD Sampling Rate Converters
Impulse Response of First order and Second Order Systems.
310.Introduction
Scilab is a scientific software package, first developed by researchers from INRIA and
ENPC, and is now developed by the Scilab Consortium. Scilab stands for scientific
laboratory. It is similar to Matlab, which is a commercial product. Yet it is almost as
powerful as Matlab.
Scilab consists of three main components:
+ an interpreter,
+ libraries of functions (Scilab procedures),
+ libraries of Fortran and C routines.
Scilab is specialized in handling matrices (basic matrix mar
transpose, inverse, etc.) and numerical computations. Also it has an open programming
environment that allows users to create their own functions and libraries.
To find the usage of any function, type help function name,
for example: help sum.
A list of common operators in Scilab:
+ Addition
= Subtraction
* Multiplication
/ Division
* Power
° Complex conjugate transpose
Some common functions in Scilab are: sin, cos, tan,asin, acos, atan, abs, min, max, sqrt,
ipulation, concatenation,
sum.
E.g., when we enter:
sin(0.5)
then it displays:
ans: =0.4794255
Special Constants
To enter some special constants
and
%e respectively. There are also constants %t (true) and %f (false) which are Boolean
variables
Data Structures
Scilab supports many data structures. Examples a1
polyno-
mial, Boolean, string, function, list, tlist, sparse,library.
Strings
To enter strings, enclose the string with either single or double quotations. For example:
“This is a string’ or “this is also a string”.To concatenate strings, use the operator + :
“Welcome” + “to” +'Scilab!”
ans: =
‘Welcome to Scilab!
‘There are some basic string handling functions such as strindex, strsplit, strsubst and part.
¢, i (sqrt(-1) ) and e. It is done by entering %pi, %i
usual (real or complex matrices),Saving and Loading Variables
To save and load variables, we use save and load functions:
save(‘file name’, varl, var2, ... );
Joad(‘file name’, ‘varl’, ‘var2’, .. .);
where file name is the name of the file to be saved or loaded, and varl, var2, . . . are
names of variable.
; b = %f; s = ‘scilab’;
save(‘save.dat’, a, b, s);
clear a; // delete the variable a
clear b;
clear s;
load(‘save.dat’, ‘a’, *b’, ‘s");
Entering Matrices
There are many ways to enter a matrix. Here is the simplest method:
1. separate each elements in a row using a blank space or a comma;
2. separate each row of elements with a semi-colon;
3. put the whole list of elements in a pair of square brackets.
For example, we wish to enter a 3 x 3 magic square and assign to the variable M.
M=[816;357;492]
asa
long vector formed by stacking up the columns of the matrix.
E.g.: M(1) = 8, MQ)=3, MG) =4,
M(4) = 1, M(5) =
‘Accessing out-of-bound elements will result in an error, like entering:
MG,4)
‘error 21
invalid index
The Colon Operator
‘The colon operator is one of the most important operators in Scilab. The expression 1:10
results in a row operator with elements 1, 2,..., 10, ie.1:10
ans:
1.2.3.4.5.6.7.8.9. 10.
To have non-unit spacing we specify the increment:
1
ans:
10. 8.6.4.2
Notice that expressions like 10:-2:1, 10:-2:0.3 would produce the same result
The operator $, which gives the largest value of an index, is handy for getting the last
entry of a vector or matrix. For example, to access all elements except the last of the last
column, we type:M(L:S-1,If a whole row or a column is required . For example we want all the elements
of the second row of M. We enter:
MQ,:)
an
3.5.7.
Coneatenation
Concatenation is the process of joining smaller size matrices to form bigger ones. This is
rd by putting matrices as elements in the bigger matrix: a=[1 23]; b=[456];¢=(7
1.2.3.4,5.6.7.8.9.
Matrix Inverse and Solving Linear Systems
The command inv(M) gives the inverse of a matrix M. If the matrix is badly scaled or
nearly singular, a warming message will be displayed:
inv({1 2;2 4.0000001))
warming
matrix is close to singular or badly scaled.
Entry-wise arithmetic operations for arrays are:
+ Addition
~ Subtraction
.* Multiplication
! Power
./ Right division
-\Left division
an almost effortless method is to use the function matrix, which reshapes a matrix to a
desired
size.
M = matrix(1:10,2,5)
About Command Line
Entering a semi-colon at the end of a command line suppresses showing the result (the
answer of the expression).lt suppresses the showing of variables a, b and c.A long
command instruction can be broken with line-wraps by using the ellipsis (, . . ) at the end
of each line to indicate that the command actually continues on the next line:
$= 1-1/2 + 1/3 -1/4 + 1/5 - 1/6 + 1/7...
= U8 + 1/9 - 1/10 + W/L - 1/125
The Programming Environment
Creating Functions
Scilab has an open programming environment that enables users to make their own
functions and libraries. It is done by using the built-in editor called SciPad. To call the
editor, type scipad() or editor(), or click Editor at the menu bar.
The file extensions used by scilab are sce and sci.
To begin writing a function, we type:
functionfoutl out2,.... J=name(in! in2,. .where function is a keyword that indicates the start of a function, out, out2,.... and int,
in2,. .. are variables that are output and input of the function respectively, the variables
can be Boolean, numbers, matrices, etc, and name is the name of the function. Then we
can enter the body of the function, At the end, type endfunction to indicate the end of the
function, Comment lines
begin with //. A sample function is given as below:
function [d] = distance(x, y)
/ this function computes the distance
M/ between the origin and the point (x, y)
d= sqrt(x"2 + y'2);
endfunetion
‘Unlike Matlab, Scilab allows multiple function declaration (with different function names)
within a single file. Also Scilab allows’
Flow Control
A table of logical expressions is given below:
equal
=not equal
eater than or equal to
jess than or equal to
> greater than
0
= Ofort 1, y(O) is growing exponential
If a< 1, y(t) is decaying exponential
ALGORITHM:
1. Choose the value of n which represents the number of samples.
2, Generate the elementary discrete time impulse, step, ramp and exponential sequences.
3. Plot all the generated discrete sequences with the help of subplot () and plot2d3()
functions.
4, Assign x-axis, y-axis variables and title for each plot.PROCEDURE:
1.Open the SCILAB software.
2.Click on NEW-> SCINOTES
3.Type the program.
4.Save the program as “program name.sce”.
5.Run the file.
6.Check for errors in Command window.
7.1f there are no errors, figure will be displayed on graphic window.
PROGRAM:
1) Elementary Discrete Time Signals
Mmpluse
cle;
clear;
close;
n=10:1:10;
impluse=[zeros(1,10),ones(1,1),zeros(1,10)];
subplot(3,3,1);
xgridQ;
plot2d3(n,impluse);
xlabel(‘discrete time n');
ylabel(‘amplitude’);
title('unit impluse sequence’);
/MOnit step
=-10:1:10;
step=[zeros(1,10),ones(1,11)];
subplot(3,3,2);
xgrid();
plot2d3(n,step);
xlabel(‘discerte time n');
ylabel(‘amplitude’);
title(unit step sequence’);
/Ramp
nl=0:1:10
ramp=nl;
subplot(3,3,3);
xgridQ;
plot2d3(n1,ramp);
xlabel(‘discrete time nl’);ylabel(amplitude’;
titleCramp signal’);
/7Exponential sequence
n=-10:1:10;
1 for a<0<1
2-08
xI=a."n;
subplot(3,3,4);
xgridQ:
plo2d3(n,x1);
xlabel( 1);
ylabel('amplitude’);
title(Exponential sequence for 01
.
x2=a."n;
subplot(3,3,5);
xgrid(s
plot2d3(n,x2);
xlabel('n');
ylabelamplitude’
titleC Exponential sequence for a>1');
Mor -11
105
fs gr>p-++—t+}
2 2 eae
é st alll oF
os 6 =
hn 8 hn
exponential signal for a<-1 cosine signal
.
. jeaieey 2 s T
g ieee fae = 2
= | colt] = 2 of
ecpeecenyy 2
ooo: w Dats
fn n2
11)Signal based on Recursive Difference Equation:
ALGORITHM:
1, Choose the value of n which
2. Generate the input sinusoidal signal.
3. Find the coefficients a and b of the difference equation
4. Define the initial states of the system
5. Find the response of the system for the given difference equation
6. Plot the response of the system.
PROGRAM:
cle;
clear;
n=0:3;
y=10*sin(2*%pi*n/60);disp(y);
a=y(3)/y(2);
b=(y(4)-a*y3)/¥(2);
disp(a);
disp(b);
disp(y@));
disp(y(4));
for k=1:1:119
p(I)=y(1);
p2)=¥2);
P(k+2)=a*p(k+1)+b*p(k);
end
disp(p);
plot2d3(p);
xlabel(‘k’);
ylabel(‘Amplitude’);
title('Sinusoidal signal using Recursive difference Equation’);
OUTPUT WAVEFORM:a a
TE Graphic window
File Tools Edit?
|
| 0 0 2 3 © 69 a 7 BD 0 100 110 120 130 140
|
k
RESULT:
Generation of Elementary Discrete-Time signals / Sinusoidal waveform based
on recursive difference equation is performed.