Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Matrices Representation:
1. row matrix:
Elements in a row are separated either by using white spaces or commas e.g.: a=[1 2 4 5]
2. column matrix:
Elements which differ by a column are separated by enter or semi column e.g.: b=[1; 2; 3]
EQUIPMENTS NEEDED:
Host (PC) with windows (95/98/Me/XP/NT/2000), MATLAB software
ALGORITHM:
THEORY:
A Recursive filter has feedback from output to input, and in general its output is a function of the
previous output samples and the present and past input samples as described by the following equation
N M
y(m)=∑ak y(m − k)+∑bk x(m − k)
k =1 k =0
where {ak, bk} are the filter coefficients, and the output y(m) is a linear combination of the previous
N output samples [y(m−1),…, y(m−N)], the present input sample x(m) and the previous M input samples
[x (m−1),…, x( m−M)]. Thus a recursive filter is also known as an Infinite Impulse Response (IIR) filter.
A Non-Recursive filter has no feedback and its input-output relation is given by,
M
y(m)=∑bk x(m − k)
k =0
The output y(m) of a non-recursive filter is a function only of the input signal x(m). The response of such
a filter to an impulse consists of a finite sequence of M+1 samples, where M is the filter order. Hence, the
filter is known as a Finite Impulse Response (FIR) filter.
A first-order filter Recursive difference equation is given by,
clc;
clear all;
close all;
% Signal Frequency and Sampling Frequency
a1=2*cos(f0); a2=-1;
b1=sin(f0);
% Initial values
% output=zeros(1,200);
y1=zeros(1,200);
for i=1:200
ynm2=ynm1;
ynm1=y1(i);
%output(i)=y1(i);
end
subplot(2,1,1)
plot(1:length(y1),y1);
10 | D S P L A B Department of ECE
xlabel('Time in ms-----> ');
subplot(2,1,2)
plot(f,Ak(1:(length(y1)+1)/2));
xlabel('Frequency in Hz ')
ylabel('Magnitude in db ');
11 | D S P L A B Department of ECE
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. Define Signal.
2. Define system.
3. What is Recursive Filter.
4. What is Non-Recursive Filter.
5. Which filter is called Recursive Filter.
6. Which filter is called Non-Recursive Filter.
7. Write the first order Recursive difference equation.
8. Write the second order Recursive difference equation coefficients.
12 | D S P L A B Department of ECE
EXPERIMENT 3
TO FIND DFT / IDFT OF GIVEN DT SIGNAL
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software.
ALGORITHM:
THEORY:
Definition: The sequence of N complex numbers x0, ...,xN-1 is transformed into the sequence of N complex
numbers X0, ..., XN-1 by the DFT according to the formula
Where k =0,…..,N-1
The Discrete Fourier Transform (DFT) converts a finite list of equally spaced samples of a function into
the list of coefficients of a finite combination of complex sinusoids, ordered by their frequencies, that has
those same sample values. The DFT spectrum is periodic with period N.
Where n= 0,….,N-1
The inverse DFT is the same as the DFT, but with the opposite sign in the exponent and a 1/N factor.
13 | D S P L A B Department of ECE
PROGRAM:
clc
clear all
close all
N=length(x);
n=0:1:N-1;
k=0:1:N-1;
subplot(2,2,1);
stem(n,x)
xlabel('-----> n');
ylabel('-----> x(n)');
title('Input sequence');
wn=exp(-j*2*pi/N);
Nk=n'*k;
wn.Nk=wn.^Nk;
xk=x*wn.Nk;
subplot(2,2,2);
stem(k,xk)
xlabel('-----> k');
ylabel('-----> X(k)');
title('DFT sequence');
y=abs(xk);
subplot(2,2,3);
stem(k,y)
14 | D S P L A B Department of ECE
xlabel('-----> k');
z=angle(xk);
subplot(2,2,4);
stem(k,z)
xlabel('-----> k');
OUTPUT:
15 | D S P L A B Department of ECE
% IDFT of a given DFT sequence
N=length(x);
n=0:1:N-1;
k=0:1:N-1;
subplot(2,2,1);
stem(k,x)
xlabel('-----> k');
ylabel('-----> X(k)');
title('DFT sequence');
% IDFT of sequence
wn=exp(j*2*pi/N);
Nk=n'*k;
wn.Nk=wn.^Nk;
xn=(x*wn.Nk)/N;
subplot(2,2,2);
stem(n,xn)
xlabel('-----> n');
ylabel('-----> x(n)');
title('IDFT sequence');
y=abs(xn);
subplot(2,2,3);
stem(n,y)
xlabel('-----> n');
16 | D S P L A B Department of ECE
z=angle(xn);
subplot(2,2,4);
stem(n,z)
xlabel('-----> n');
OUTPUT:
17 | D S P L A B Department of ECE
VIVA QUESTIONS:
18 | D S P L A B Department of ECE
EXPERIMENT 4
AIM:
To find the frequency response of a given system given in (Transfer Function/ Differential equation
form).
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
1. Define the numerator & denominator coeffiecients and normalized Frequency points.
THEORY:
Frequency response is the quantitative measure of the output spectrum of a system or device in response to
a stimulus, and is used to characterize the dynamics of the system. It is a measure of magnitude and phase
of the output as a function of frequency, in comparison to the input. In simplest terms, if a sine wave is
injected into a system at a given frequency, a linear system will respond at that same frequency with a
certain magnitude and a certain phase angle relative to the input. Also for a linear system, doubling the
amplitude of the input will double the amplitude of the output. In addition, if the system is time-invariant,
then the frequency response also will not vary with time.
An LTI system's frequency response provides a similar function: it allows you to calculate the effect that a
system will have on an input signal, except those effects are illustrated in the frequency domain.
19 | D S P L A B Department of ECE
PROGRAM:
clear all;
close all;
b=[1 2];
a=[1,-0.8];
w=0:0.01:2*pi;
[h]=freqz(b,a,w);
subplot(2,1,1);
plot(w/pi,abs(h));
xlabel('normalised freq');
ylabel('magnitude');
subplot(2,1,2);
plot(w/pi,angle(h));
xlabel('normalised freq');
ylabel('phase in radians');
figure(2)
zplane(b,a)
20 | D S P L A B Department of ECE
Output:
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
normalised freq
1
phase in radians
0.5
-0.5
-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
normalised freq
Result:
The frequency response of a given system given in Transfer Function ( Differential equation form) is
obtained.
VIVA QUESTIONS:
21 | D S P L A B Department of ECE
EXPERIMENT 6
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
THEORY:
The Fast Fourier Transform is useful to map the time-domain sequence into a continuous function of a
frequency variable. The FFT of a sequence {x(n)} of length N is given by a complex-valued sequence
X(k).
M nk
j 2
X ( k ) x ( n) e n
;0 k N 1
k 0
The above equation is the mathematical representation of the DFT. As the number of computations
involved in transforming a N point time domain signal into its corresponding frequency domain signal was
found to be N2 complex multiplications, an alternative algorithm involving lesser number of computations
is opted.
When the sequence x(n) is divided into 2 sequences and the DFT performed separately, the resulting
number of computations would be N2/2
(i.e.)
N2 N2
21 21
x(k ) x(2n) WN2 nk x(2n 1) WN( 2 n1) k
n 0 n 0
Consider x(2n) be the even sample sequences and x(2n+1) be the odd sample sequence derived form x(n).
N2
21
x ( 2 n)
n 0
WN2 nk
would result in
22 | D S P L A B Department of ECE
N2
21
N2 N2 N2
= Computations
4 4 2
N2 N
21 21 k
x ( k ) x ( 2n ) W 2 nk
N x(2n 1) W ( 2 nk )
N W
N
n 0 n 0
N N
21 k 21
x(2n) WN2 nk W x(2n 1) WN( 2 nk )
N
n 0 n 0
Dividing the sequence x(2n) into further 2 odd and even sequences would reduce the computations.
j 2
WN = Twiddle factor e n
j 2
nk
W nk
N e n
N N j 2 j 2 n
K K k
W
N
2
WN W
N
2
e n
e n 2
j 2
k
W k
N e n
WNk (cos j sin )
N N
K K
W
N
2
W (1) W
k
N
N
2
WNk
Employing this equation, we deduce
23 | D S P L A B Department of ECE
N2 N
21 21
x(k ) x(2n) WN2 nk x(2n 1) WN( 2 nk )
n 0 n 0
N
21 K N
N
x(k ) x(2n) WN W x(2n 1) 21 WN( 2 nk )
2 nk
2 n 0 N
The time burden created by this large number of computations limits the usefulness of DFT in many
applications. Tremendous efforts devoted to develop more efficient ways of computing DFT resulted
in the above explained Fast Fourier Transform algorithm. This mathematical shortcut reduces the
number of calculations the DFT requires drastically. The above mentioned radix-2 decimation in time
FFT is employed for domain transformation.
Dividing the DFT into smaller DFTs is the basis of the FFT. A radix-2 FFT divides the DFT into two
smaller DFTs, each of which is divided into smaller DFTs and so on, resulting in a combination of
two-point DFTs. The Decimation -In-Time (DIT) FFT divides the input (time) sequence into two
groups, one of even samples and the other of odd samples. N/2 point DFT are performed on the these
sub-sequences and their outputs are combined to form the N point DFT.
The above shown mathematical representation forms the basis of N point FFT and is called the Butterfly
Structure.
24 | D S P L A B Department of ECE
STAGE – I STAGE - II
STAGE – III
25 | D S P L A B Department of ECE
PROGRAM:
%% Clear Section
clear all;
close all;
clc;
Fs = 1000;
T = 1/ Fs;
t = 0:T:10;
rxx = xcorr(x,x);
Sxx = fft(rxx,N);
Plot(f,abs(Sxx));
Xlabel(‘frequency’);
Ylabel(‘abs(Sxx)’);
26 | D S P L A B Department of ECE
OUTPUT:
RESULT:
VIVA QUESTIONS:
1. What is FF T?
2. Why FF T is needed?
3. What is radix-2 FFT?
4. How many multiplications and additions are required to compute N point DF T using
radix-2 FFT?
5. What is DIT algorithm?
6. What DIF algorithm?
7. What are the applications of FF T algorithm?
8. Why the computations in FF T algorithm is said to be in place?
9. What are the differences and similarities between DIF and DIT algorithms?
10. What is phase factor or twiddle factor?
11. Draw and explain the basic butterfly diagram or flow graph of DIT radix-2 FF T.
12. What is DIT radix-2 FF T?
13. Draw and explain the basic butterfly diagram or flow graph of DIF radix-2 FFT.
14. Compare the DIT and DIF radix-2 FF T.
27 | D S P L A B Department of ECE
EXPERIMENT 7
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
THEORY:
Power Spectral Densfty (PSD) is the frequency response of a random or periodic signal. It tells us where
the average power is distributed as a function of frequency.
The PSD is deterministic, and for certain types of random signals is independent of time1. This is
useful because the Fourier transform of a random time signal is itself random, and therefore of
little use calculating transfer relationships (i.e., finding the output of a filter when the input is
random).
The PSD of a random time signal x(t) can be expressed in one of two ways that are equivalent to
each other
1. The PSD is the average of the Fourier transform magnitude squared, over a large time interval
1
2
x(t)e
T
j 2ft
S x ( f ) lim E dt
T 2T
T
R ( )e
T
j 2ft
Sx ( f ) x dt
T
28 | D S P L A B Department of ECE
Rx ( ) Ex(t ) x * (t )
The power can be calculated from a random signal over a given band of frequencies as follows:
1. Total Power in x(t): P
S ( f )df R (0)
x x
S ( f )df R (0)
f2
2. Power in x(t) in range f1 - f2: P12 x x
f1
1
The signal has to be stationary, which means that us statistics do not change as a function of time.
4. The auto-correlation function and PSD are a Fourier transform pair. To compute PSD, we compute
the auto-correlation of the signal and then take its FFT.
5. The value of the auto-correlation function at zero-time equals the total power in the signal.
Keep in mind that total or the average power in a signal is often not of as great an interest. We are
most often interested in the PSD or the Power Spectrum. We often want to see is how the input
power has been redistributed by the channel and in this frequency-based redistribution of power is
where most of the interesting information lies
29 | D S P L A B Department of ECE
PROGRAM
clc;
clear all;
close all;
Fs=100;
N=512;
t=0:1/Fs:10;
f=Fs*(0:N-1)/N;
%x=sin(2*pi*15*t)+sin(2*pi*30*t);
rxx= xcorr(x,x);
Sxx=fft(rxx,N);
plot(f,abs(Sxx));
xlabel('frequency f');
ylabel('abs(Sxx)');
30 | D S P L A B Department of ECE
Output:
x 10
4
Power Spectral Density
3.5
2.5
abs(Sxx)
1.5
0.5
0
0 10 20 30 40 50 60 70 80 90 100
frequency f
31 | D S P L A B Department of ECE
VIVA QUESTIONS:
32 | D S P L A B Department of ECE
EXPERIMENT 8
AIM:
Design LP FIR filter and verify with different cutoff frequencies using matlab software.
EQUIPMENTS:
ALGORITHM:
THEORY:
A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system whose output is based
on the weighted summation of a finite number of past inputs. An FIR transversal filter structure can be
obtained directly from the equation for discrete-time convolution.
N 1
y ( n) x ( k ) h( n k ) 0 n N 1
k 0
In this equation, x(k) and y(n) represent the input to and output from the filter at time n. h(n-k) is the
transversal filter coefficients at time n.
FIR filters are digital filters with finite impulse response. They are also known as non-recursive
digital filters as they do not have the feedback (a recursive part of a filter), even though recursive
algorithms can be used for FIR filter realization.
Most FIR filter design methods are based on ideal filter approximation. The resulting filter approximates
the ideal characteristic as the filter order increases, thus making the filter and its implementation more
complex.
The filter design process starts with specifications and requirements of the desirable FIR filter. Which
method is to be used in the filter design process depends on the filter specifications and implementation.
This chapter discusses the FIR filter design method using window functions.
33 | D S P L A B Department of ECE
Each of the given methods has its advantages and disadvantages. Thus, it is very important to carefully
choose the right method for FIR filter design. Due to its simplicity and efficiency, the window method is
most commonly used method for designing filters. The sampling frequency method is easy to use, but
filters designed this way have small attenuation in the stopband.
As we have mentioned above, the design process starts with the specification of desirable FIR filter.
Figure 1 illustrates a low-pass digital filter specification. The word specification actually refers to the
frequency response specification.
where:
34 | D S P L A B Department of ECE
fs is a sampling frequency;
f is a frequency to normalize; and
ω is normalized frequency.
PROGRAM:
n=20;
fp=200;
fq=300;
fs=1000;
fn=2*fp/fs;
window=rectwin(n+1);
b=fir1(n,fn,window);
[H W]=freqz(b,1,128);
subplot(2,1,1);
plot(W/pi,abs(H));
ylabel('gain in db-------->');
xlabel('normalized frequency------>');
subplot(2,1,2);
plot(W/pi,angle(H));
ylabel('angle-------->');
xlabel('normalized frequency------>');
35 | D S P L A B Department of ECE
OUTPUT:
n=20;
fp=200;
fq=300;
fs=1000;
fn=2*fp/fs;
window=blackman(n+1);
b=fir1(n,fn,window);
[H W]=freqz(b,1,128);
subplot(2,1,1);
plot(W/pi,abs(H));
36 | D S P L A B Department of ECE
ylabel('gain in db-------->');
xlabel('normalized frequency------>');
subplot(2,1,2);
plot(W/pi,angle(H));
ylabel('angle-------->');
xlabel('normalized frequency------>');
OUTPUT:
RESULT:
37 | D S P L A B Department of ECE
VIVA QUESTIONS:
38 | D S P L A B Department of ECE
EXPRIMENT: 9
AIM: - TO write a MATLAB program to Amplitude response and response of Butter worth high pass
filter
ALGORITHM:
THEORY:
The IIR filter can realize both the poles and zeroes of a system because it has a rational transfer
function, described by polynomials in z in both the numerator and the denominator:
M
b
k 0
k z k
H ( z) N
a
k 1
k Z k
M and N are order of the two polynomials, bk and ak are the filter coefficients.
IIR filters are digital filters with infinite impulse response. Unlike FIR filters, they have the feedback
(a recursive part of a filter) and are known as recursive digital filters.
For this reason IIR filters have much better frequency response than FIR filters of the same order.
Unlike FIR filters, their phase characteristic is not linear which can cause a problem to the systems
which need phase linearity. For this reason, it is not preferable to use IIR filters in digital signal
39 | D S P L A B Department of ECE
processing when the phase is of the essence. Otherwise, when the linear phase characteristic is not
important, the use of IIR filters is an excellent solution.
The most commonly used IIR filter design method uses reference analog prototype filter. It is the best
method to use when designing standard filters such as low-pass, high-pass, bandpass and band-stop
filters.
Figure 1 illustrates a High-pass digital filter specification. The word specification refers to the
frequency response specification.
40 | D S P L A B Department of ECE
Frequency normalization can be expressed as follows:
where:
PROGRAM:-
clc;
close all;
clear all;
format long;
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
[z,p,k]= butter(n,wn);
[b,a]=butter(n,wn,'high','s');
41 | D S P L A B Department of ECE
w=0:0.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('gain in db--------->');
subplot(2,1,2);
plot(om/pi,an);
ylabel('phase in db--------->');
42 | D S P L A B Department of ECE
INPUT
OUTPUT
VIVA QUESTIONS:
44 | D S P L A B Department of ECE
EXPERIMENT ; 10
EQUIPMENTS NEEDED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
THEORY:
A digital filter is characterized by its transfer function, or equivalently, its difference equation.
Mathematical analysis of the transfer function can describe how it will respond to any input. As such,
designing a filter consists of developing specifications appropriate to the problem (for example, a second-
order low pass filter with a specific cut-off frequency), and then producing a transfer function which meets
the specifications.
The transfer function for a linear, time-invariant, digital filter can be expressed as a transfer function in
the Z-domain; if it is causal, then it has the form:
This is the form for a recursive filter with both the inputs (Numerator) and outputs (Denominator),
which typically leads to an IIR infinite impulse response behavior, but if the denominator is made
equal to unity i.e. no feedback, then this becomes an FIR or finite impulse response filter.
45 | D S P L A B Department of ECE
PROGRAM
clc;
close all;
clear all;
% fs=input('enter the sampling frequency which is greater than twice the signal frequency= ');
b0=0;
b1=sin(f0);
a0=1;
a1=-2*cos(f0);
a2=1;
%% Filtering Operation
y=filter(b,a,x);
subplot(2,1,1)
xlabel('Time in Seconds');
46 | D S P L A B Department of ECE
title(['Sinusoidal Signal of frequency ', num2str(f_hz), ' Hz']);
Ak(1)=Ak(1)/2;
subplot(2,1,2)
xlabel('Frequency in Hz')
OUTPUT
47 | D S P L A B Department of ECE
VIVA QUESTIONS:
48 | D S P L A B Department of ECE
EXPERIMENT : 11
EQUIPMENTS NEEDED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
THEORY:
DTMF (Dual tone multi frequency) as the name suggests uses a combination of two sine wave tones to
represent a key. These tones are called row and column frequencies as they correspond to the layout of a
telephone keypad.
49 | D S P L A B Department of ECE
DTMF keypad (generator or encoder) generates a sinusoidal tone which is mixture of the row and
column frequencies. The row frequencies are low group frequencies. The column frequencies belong to
high group frequencies. This prevents misinterpretation of the harmonics. Also the frequencies
for DTMF are so chosen that none have a harmonic relationship with the others and that mixing the
frequencies would not produce sum or product frequencies that could mimic another valid tone. The high-
group frequencies (the column tones) are slightly louder than the low-group to compensate for the high-
frequency roll off of voice audio systems.
The row and column frequencies corresponding to a DTMF keypad have been indicated in the
above figure.
DTMF tones are able to represent one of the 16 different states or symbols on the keypad. This is
equivalent to 4 bits of data, also known as nibble.
Mark and Space refer to the duration a Dtmf tone is produced, as well as the duration of the silence
between individual digits.
The time which a DTMF digit tone is actually producing sound, is called the "Mark" time. The silence
between each one of the digits is called the "Space". Most DTMF decoders and controllers will list a
minimum Mark/Space speed, expressed in milliseconds.
The standard for most radio decoders, as well as most telephone equipment is 40/40. The decoders expect
the DTMF tones to exist for at least 40 milliseconds, with 40 milliseconds of silence in between each
DTMF digit.
PROGRAM:
clc;
close all;
clear all;
50 | D S P L A B Department of ECE
% fs=input('enter the sampling frequency which is greater than twice the max. signal frequency= ');
%fL=input('enter any one low frequency value from [697 770 852 941] vector= ');
bL=[0 sin(2*pi*fL/fs)];
% Output of HL(z)
yL=filter(bL,aL,x);
%fH=input('enter any one High frequency value from [1209 1336 1477] vector= ');
bH=[0 sin(2*pi*fH/fs)];
% Output of HH(z)
yH=filter(bH,aH,x);
y_LH=yL+yH;
key=1;
51 | D S P L A B Department of ECE
disp(' Generated DTMF tone is for key 1');
end
key=2;
end
key=3;
end
key=4;
end
key=5;
end
key=6;
end
key=7;
end
key=8;
52 | D S P L A B Department of ECE
end
key=9;
end
key='*';
end
key=0;
end
key='#';
end
subplot(2,1,1)
xlabel('Time in Seconds');
Mag_spec(1)=Mag_spec(1)/2;
subplot(2,1,2)
53 | D S P L A B Department of ECE
plot(f,Mag_spec(1:(length(y_LH)+1)/2)); % Plot upto folding frequency
grid
xlabel('Frequency in Hz')
title(['Magnetude Spectrum of DTMF Tone for key ', num2str(key),' at ' num2str(fL),' Hz & at ',
num2str(fH),' Hz']);
OUTPUT
54 | D S P L A B Department of ECE
VIVA QUESTIONS:
55 | D S P L A B Department of ECE
EXPERIMENT: 12
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software.
ALGORITHM:
1. Generate the discrete signal.
2. Calculate the length of the signal.
3. Perform Down Sampling operation using a factor.
4. Draw the Down Sampled signal.
THEORY:
The sampling rate alteration that is employed to generate a new sequence with a sampling rate higher or
lower than that of a given sequence. Thus, if x[n] is a sequence with a sampling rate of F T Hz and it is
used to generate another sequence y[n] with a desired sampling rate of FT' Hz, then the sampling rate
alteration ratio is given by FT' / FT = R.
If R < 1, the sampling rate is decreased by a process called decimation and it results in a sequence with a
lower sampling rate.
The decimation can be carried out by using the pre-defined commands decimate.
PROGRAM:
clc;
clear all;
close all;
56 | D S P L A B Department of ECE
dt=1/fs;
t=dt:dt:T
M=length(t);
m=cos(2*pi*fm*t);
r=input('Enter the factor by which the sampling frequency has to be reduced r: ');
md=decimate(m,r);
figure(1);
subplot(3,1,1);
plot(t,m);
grid;
xlabel('t-->');
ylabel('Amplitude-->');
subplot(3,1,2);
stem(m);
grid;
xlabel('n-->');
ylabel('Amplitudes of m -->');
subplot(3,1,3);
stem(md);
grid;
xlabel('n/r-->');
ylabel('Amplitude of md-->');
57 | D S P L A B Department of ECE
OUTPUT
58 | D S P L A B Department of ECE
VIVA QUESTIONS:
59 | D S P L A B Department of ECE
EXPERIMENT : 13
EQUIPMENTS REQUIRED:
ALGORITHM:
1. Generate the discrete signal.
2. Calculate the length of the signal.
3. Perform Up Sampling operation using a factor.
4. Draw the Up Sampled signal.
THEORY:
The sampling rate alteration that is employed to generate a new sequence with a sampling rate higher or
lower than that of a given sequence. Thus, if x[n] is a sequence with a sampling rate of F T Hz and it is
used to generate another sequence y[n] with a desired sampling rate of FT' Hz, then the sampling rate
alteration ratio is given by FT' / FT = R.
If R > 1, the process is called interpolation and results in a sequence with a higher sampling rate.
PROGRAM:
clc;
clear all;
close all;
dt=1/fs;
t=dt:dt:T
M=length(t);
60 | D S P L A B Department of ECE
m=cos(2*pi*fm*t);
r=input('Enter the factor by which the sampling frequency has to be increased r: ');
md=interp(m,r);
figure(1);
subplot(3,1,1);
plot(t,m);
grid;
xlabel('t-->');
ylabel('Amplitude-->');
subplot(3,1,2);
stem(m);
grid;
xlabel('n-->');
ylabel('Amplitudes of m -->');
subplot(3,1,3);
stem(md);
grid;
xlabel('n x r-->');
ylabel('Amplitude of md-->');
OUTPUT
61 | D S P L A B Department of ECE
Figure: A sine signal before Interpolation & after Interpolation
VIVA QUESTIONS:
62 | D S P L A B Department of ECE
EXPERIMENT: 14
AIM:
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
THEORY:
Considering the general case of sampling rate conversion by a rational factor input basically we can
achieve this sampling rate conversion by performing interpolation by the factor output of the I/D is
accomplished by cascading and interpolation by the denominator. The filter with the impuse response {
h(k) & hd(k)} input is decomplished by cascading and interpolation with a denominator.
M L
PROGRAM:
clc
clear all
close all
%y(n0=y(n-1)+0.9y(n-2)=x(n)+0.5x(n-1)+0.5x(n-2)
n=0:N-1;
x= sin(2*pi*0.043*n)+sin(2*pi*0.031*n);
y=resample(x,L,M);
subplot(2,1,1);
stem(n,x(1:N));
xlabel(‘time-’);
63 | D S P L A B Department of ECE
ylabel(‘amplitude-’);
title(‘input sequence’);
subplot(2,1,2);
stem(y(1:N*L/M));
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘output sequence’);
Result:- Hence the implementation of I/D sampling rate conversion was observed by using matlab
software.
64 | D S P L A B Department of ECE
EXPERIMENT : 15
AIM:
Find the impulse response of first order and second order systems.
EQUIPMENTS REQUIRED:
Host (PC) with windows (95/98/Me/XP/NT/2000), matlab software
ALGORITHM:
4. Find the impulse response of first order and second order systems.
THEORY:
A system's impulse response (often annotated as h(t)for continuous-time systems or h[n] for discrete-time
systems) is defined as the output signal that results when an impulse is applied to the system input. The
impulse response of the system is given as,
where h[n] is the system's impulse response. The above equation is the convolution theorem for discrete-
time LTI systems. That is, for any signal x[n] that is input to an LTI system, the system's output y[n] is
equal to the discrete convolution of the input signal and the system's impulse response.
PROGRAM:
clc
clear all
close all
65 | D S P L A B Department of ECE
% y(n0=y(n-1)+0.9y(n-2)=x(n)+0.5x(n-1)+0.5x(n-2)
a=[1 1 0.9];
x=[1 zeros(1,N)];
y=filter(b,a,x);
subplot(2,1,1)
stem(1:length(x),x);
xlabel('Time');
ylabel('Amplitude');
title('Impulse Sequence');
subplot(2,1,2)
stem(1:length(y),y);
xlabel('Time');
ylabel('Amplitude');
66 | D S P L A B Department of ECE
OUTPUT
RESULT: The impulse response of first order and second order systems are obtained.
VIVA QUESTIONS:
67 | D S P L A B Department of ECE