0% found this document useful (0 votes)
20 views18 pages

DSP Labsheet

The document outlines a series of experiments related to Digital Signal Processing conducted by the Department of Electronics and Telecommunication Engineering at CUET. It includes objectives, theoretical background, procedures, and exercises for experiments on sampling, quantization, convolution, and correlation of discrete-time signals using MATLAB. Each experiment aims to analyze different effects and properties of signals, providing hands-on experience with practical applications in signal processing.

Uploaded by

Nazrul Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views18 pages

DSP Labsheet

The document outlines a series of experiments related to Digital Signal Processing conducted by the Department of Electronics and Telecommunication Engineering at CUET. It includes objectives, theoretical background, procedures, and exercises for experiments on sampling, quantization, convolution, and correlation of discrete-time signals using MATLAB. Each experiment aims to analyze different effects and properties of signals, providing hands-on experience with practical applications in signal processing.

Uploaded by

Nazrul Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Digital Signal Processing ©Dept.

of ETE, CUET

CONTENTS
Experiment Experiment Name Remarks
No.

01 Effects of Sampling and Quantization in Discrete Time


Continuous Valued Signals
02 Effect of Convolution on Discrete-time Signal

03 Effect of Correlation on Discrete-time Signal

04 Studying Discrete Fourier Transform using an audio signal

05 Studying z transform in MATLAB

06 Designing FIR and IIR Filtersusing MATLAB

07 Computation of Power Density Spectrum of a Sequence


Using MATLAB
Digital Signal Processing ©Dept. of ETE, CUET

CHITTAGONG
HITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ELECTRONICS
ELECTRONICS & TELECOMMUNICATION ENGINEERING
CHITTAGONG
CHITTAGONG-4349, BANGLADESH.
COURSE NO.: ETE 310
COURSE TITLE: DIGITAL SIGNAL PROCESSING SESSIONAL
Experiment No.
Name of Experiment: Effects of Sampling and Quantization in Discrete Time
Continuous ValuedSignals

OBJECTIVE:
1. For analyzing sampling effect-
1.1. Simulate and plot two CT signals of 10 Hz and 110 Hz for 0 < t < 0.2 secs.
1.2. Sample at Fs = 100 Hz and plot them in discrete form.
1.3. Observe and note the aliasing effects.
2. For analyzing quantization effect-
effect
2.1. Simulate a DTCV sinusoid of 1/50 cycles/sample with length of the signal be 500.
2.2. Choose the no. of significant digits for
fo round-off
off and apply to the signal generated above.
2.3. Compute the error signals and SQNR

THEORY:

Quantization: In this session, we will generate DTCV sinusoids and quantize them. We
shall measure thequantization noise signals and the quality of the quantization process.
The error signal is given as: xe(n) = x(n) - xq(n). Where, xq(n) is the quantized signal.
The resolution of the quantizer is given as:

, where L is the no. ofquantization levels.The quality of thequantized


signal is measured by the signal-to-quantization
signal quantization noise ratio(SQNR) which is
mathematically written as:

, Px and Pe are averagepowers of the DTCV and quantizedsignal


respectively, and may be written as:
Digital Signal Processing ©Dept. of ETE, CUET

PROCEDURE:
1. For analyzing sampling effect-
effect

 Make a folder at desktop and name it as your current directory within MATLAB.
 Open M-file
file editor and type the following code:
clear all;
close all;
clc;
F1 = 10;
F2 = 110;
Fs = 100;
Ts = 1/Fs;
t = [0 : 0.0005 : 0.2];
x1t = cos(2*pi*F1*t);
x2t = cos(2*pi*F2*t);
figure,
plot(t,x1t,t,x2t, 'LineWidth',2);
'LineWidth'
xlabel('cont time (sec)');
ylabel('Amp');
xlim([0 0.1]);
grid on;
legend('10Hz','110Hz');
title('Two
'Two CTCV sinusoids plotted');
plotted'

 Save the file as P011.m in your current directory and ‘run’ it, either using F5 key or
writing the file name at the command window.
 Check for the correctness of the time periods of both sinusoids.
 Now add the following bit of code at the bottom of your P011.m file and save.
nTs = [0 : Ts : 0.2];
n = [1 : length(nTs)-1 ];
x1n = cos(2*pi*F1*nTs);
x2n = cos(2*pi*F2*nTs);
figure,
subplot(2,1,1),
stem(nTs,x1n,'LineWidth',2);
,2);
grid on;
title('10Hz sampled');
xlabel('discrete
'discrete time (sec)');
(sec)'
ylabel('Amp');
xlim([0 0.1]);
subplot(2,1,2)
stem(nTs,x2n,'LineWidth',2);
,2);
grid on;
title('110Hz sampled')
xlabel('discrete
ete time (sec)');
(sec)'
ylabel('Amp');
xlim([0 0.1]);

 Before hitting the ‘run’, just try to understand what the code is doing and try to link it with
what we have studied in classes regarding concepts of frequency for DT signals.
 Now ‘run’ the file and observe both plots.
Digital Signal Processing ©Dept. of ETE, CUET

 To see what is really happening, type the following code at the bottom of your existing
P011.m file and run again.
figure,
plot(t,x1t,t,x2t);
hold
stem(nTs,x1n,'r','LineWidth',2);
xlabel('time (sec)');
ylabel('Amp');
xlim([0 0.05]);
legend('10Hz','110Hz');
 Observe the plots.

RESULT:
Explain (write) in your own words the cause and effects of what you just saw.

EXERCISE:
This needs to be completed before your next practical and saved.

Consider the following CT signal: x(t) = sin (2 pi F0 t). The sampled version will be: x(n) =
sin (2 pi F0/Fs n), where n is a set of integers and sampling interval Ts=1/Fs.
Plot the signal x(n) for n = 0 to 99 for Fs = 5 kHz and F1 = 0.5, 2, 3 and 4.5 kHz. Explain the
similarities and differences among various plots.

2. For analyzing quantization effect-


 Make a folder at desktop and name it as your current directory within MATLAB.
 Open M-file editor and write the following code:
clear all;
close all;
clc;
fd1 = 1/50;
n = [0 : 499 ];
q=input('No. of Digits after decimal points to be retained (0-9): ');
x1 = cos(2*pi*fd1*n);
Px1 = sum(abs(x1).^2)/length(x1);
x1q = round(x1*10^q)/10^q;
x1e = x1 - x1q;
Pe1 = sum(abs(x1e).^2)/length(x1e);
SQNR = 10*log10(Px1/Pe1);
disp(['The Signal to Quantization Noise Ratio is: ' num2str(SQNR) '
dB.' ]);
figure,
subplot(2,1,1);
plot(n,x1,n,x1q);
xlabel('indices');
ylabel('Amp');
xlim([0 49]);
ylim([-1.1 1.1]);
legend('DTCV','DTDV');
subplot(2,1,2);
plot(n,x1e);
xlabel('indices');
ylabel('Error');
xlim([0 49]);

 Save the file as P021.m in your current directory and run it.
Digital Signal Processing ©Dept. of ETE, CUET

 Explore and take notes.


 Now modify the above code as follows and save as another file P022.m.
clear all;
close all;
clc;
fd1 = 1/50;
n = [0 : 499 ];
q = [0 : 10]; % No. of Digits after decimal points to be retained
for num = 1 : length(q)
x1 = cos(2*pi*fd1*n);
Px1 = sum(abs(x1).^2)/length(x1);
x1q = round(x1*10^q(num))/10^q(num);
x1e = x1 - x1q;
Pe1 = sum(abs(x1e).^2)/length(x1e);
SQNR(num) = 10*log10(Px1/Pe1);
end
figure,
plot(q,SQNR);
xlabel('Significant Digits');
ylabel('SQNR (dB)');
ylabel('SQNR (dB)');
xlim([q(1) q(end)]);

 6. Before hitting the ‘run’, just try to understand what the code is doing and try to link it with
the previous code.
 Now ‘run’ the file and observe the results.

RESULT:

Explain (write) in your own words the cause and effects of what you just saw.
Digital Signal Processing ©Dept. of ETE, CUET

CHITTAGONG
HITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ELECTRONICS
ELECTRONICS & TELECOMMUNICATION ENGINEERING
CHITTAGONG
CHITTAGONG-4349, BANGLADESH.
COURSE NO.: ETE 310
COURSE TITLE: DIGITAL SIGNAL PROCESSING SESSIONAL
Experiment No.
Name of Experiment: Effect of Convolution on Discrete-time
time Signal

OBJECTIVE:
1. We have the impulse response of a system as h( n) = {3, 2,1, −2,1, 0, −4,4, 0, 3}.

2. For x (n) = {1, −2,3, −4,3,
4,3, 2,1} , find y(n).

3. Modify the code such that h (n) = {3, 2,1, −2,1,0, −4,0,3}- (origin is shifted), and check

the causality property mentioned above (Theory – point 3).

THEORY:

1. Convolution is given as:

i.e. one can compute the output y(n) to a certain input x(n) when impulse response h(n) of that
system is known. Convolution holds commutative property.
2. The length of the resulting convolution sequence is N+M-1, where, N and M are the
lengths of the two convolved signals respectively.
3. In Causal Systems, the output only depends on the past and/or present values of inputs and
NOT on future values. This means that the impulse response h(n) of a causal system will
always exist only for n ≥ 0.

PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Open M-file
file editor and write the following code:

clear all;
close all;
clc;
h = [3 2 1 -2 1 0 -4
4 0 3]; % impulse response
Digital Signal Processing ©Dept. of ETE, CUET

org_h = 1; % Sample number where origin exists


nh = [0 : length(h)-1]- org_h + 1;
x = [1 -2 3 -4 3 2 1]; % input sequence
org_x = 1; % Sample number where origin exists
nx = [0 : length(x)-1]- org_x + 1;
y = conv(h,x);
ny = [nh(1)+ nx(1) : nh(end)+nx(end)];
figure,
subplot(3,1,1),
stem(nh,h);
xlabel('Time index n'); ylabel('Amplitude');
xlim([nh(1)-1 nh(end)+1]);
title('Impulse Response h(n)'); grid;
subplot(3,1,2),
stem(nx,x);
xlabel('Time index n'); ylabel('Amplitude');
xlim([nx(1)-1 nx(end)+1]);
title('Input Signal x(n)'); grid;
subplot(3,1,3)
stem(ny,y);
xlabel('Time index n'); ylabel('Amplitude');
xlim([ny(1)-1 ny(end)+1]);
title('Output Obtained by Convolution'); grid;

3. Save the file as P031.m in your current directory and ‘run’ it.
4. Try to learn, explore the code and make notes.
5. Now modify the above code as mentioned in objectives above and check for causality.

RESULT:

EXERCISE:
1. What will happen if we input x(n)={0,0,1,0,0} into the above system.

2. Can you prove commutative property of the convolution?
3. Modify the code to prove Associative and Distributive properties of the convolution
Signals and Systems ©Dept. of ETE, CUET

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY


DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING
CHITTAGONG-4349, BANGLADESH.
COURSE NO.: ETE 310
COURSE TITLE: DIGITAL SIGNAL PROCESSING SESSIONAL
Experiment No.
Name of Experiment: Effect of Correlation on Discrete-time Signal

OBJECTIVE:
1. Generate two sinusoids of length 10 and fd = 0.1 with variable phase.
2. Apply correlation and check for certain properties such as magnitude and location of
maximum correlation with varying phases.
3. Also, to verify whether the lag zero auto-correlation gives the energy of the signal.
4. Compute correlation using convolution command.

THEORY:

∞∞
1.Correlation is given as: rxy (l) =∑x (n) y (n−l) =∑x (n+l) y (n).. Where ‘l’ is thelag.

n =−∞ n=−∞
This is called cross-correlation and it gives the magnitude and location of similarity between two
signals. The correlation between y(n) and x(n) is not necessarily the same as
thecorrelationbetween x(n) and y(n). It is given as:
∞∞
ryx(l )=∑ y (n )x (n − l )=∑ y (n + l )x (n).
n =−∞n =−∞

2. Generally, rxy (l )=ryx (−l) . These two are the same when x(n) and y(n) are the samesignals or
when x(n) and y(n) are even symmetric signals.
Signals and Systems ©Dept. of ETE, CUET

3. The length of the resulting correlation sequence is N+M-1, where, N and M are the lengths of
the two signals

4. Correlation may also be computed using convolution algorithm with a modification that we
need to fold one of the signals before applying the convolution. Mathematically,

rxy( n)= x ( n )∗ y (−n).

PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB.

2. Open M-file editor and write the following code:

clear all;
close all;
clc;
n = [0:9];
ph1 = 0;
ph2 = 0;
x = sin(2*pi*0.1*n + ph1);
org_x = 1;
nx = [0 : length(x)-1]- org_x + 1;
y = sin(2*pi*0.1*n + ph2);
org_y = 1;
ny = [0 : length(y)-1]- org_y + 1;
rxy = xcorr(x,y);
nr = [nx(1)-ny(end) :nx(end)-ny(1)];
[maxRindR] = max(rxy);
disp(['The correlation at lag zero is: ' num2str(rxy(find(nr==0))) '.']);
disp(['The maximum correlation is at lag ' num2str(nr(indR)) '.']);
figure,
subplot(3,1,1),
stem(nx,x);
xlabel('Time index n'); ylabel('Amplitude'); xlim([nx(1)-1 nx(end)+1]);
title('Signal x(n)'); grid;
subplot(3,1,2),
stem(ny,y);
xlabel('Time index n'); ylabel('Amplitude'); xlim([ny(1)-1 ny(end)+1]);
title('Signal y(n)'); grid;
subplot(3,1,3)
stem(nr,rxy);
xlabel('Time index n'); ylabel('Amplitude'); xlim([nr(1)-1 nr(end)+1]);
title('Cross Correlation'); grid;

RESULT:
Explain (write) in your own words the cause and effects of what you just saw.

EXERCISE:
Modify the code, such that the correlation is obtained using convolution command.
Signals and Systems ©Dept. of ETE, CUET

CHITTAGONG
HITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ELECTRONICS
ELECTRONICS & TELECOMMUNICATION ENGINEERING
CHITTAGONG
CHITTAGONG-4349, BANGLADESH.
COURSE NO.: ETE 310
COURSE TITLE: DIGITAL SIGNAL PROCESSING SESSIONAL
Experiment No.
Name of Experiment: Studying Discrete Fourier Transform using an audio
signal
OBJECTIVE:
1. Load an audio file ‘noisy.wav’ into Matlab.
2. There is a tone added to the speech in this file. The objective is to find the frequency of this
tone.
3. Computing the DFT of this signal;
4. Generating frequency vector in Hz.
5. Displaying the DFT and observing the frequency of the added tone.

THEORY:

 DF analysis equation:

 DFT synthesis equation:

 Frequency Resolution is given by:


by

 Sample frequencies are given by:


by

PROCEDURE:
Signals and Systems ©Dept. of ETE, CUET

1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Copy the audio file ‘noisy.wav’ into your current directory.
3. Open M file editor and write the following code:

clear all;
clc;
close all;
[y,Fs,bits] = wavread('noisy.wav');
Ts = 1/Fs;
n = [0:length(y)-1];
t = n.*Ts;
k = n;
Df = Fs./length(y);
F = k.*Df;
Y = fft(y);
magY = abs(Y);
sound(y,Fs);
figure,
subplot(2,1,1);
plot(F,magY);
grid on;
xlim([0 Fs/2]);
xlabel('Frequency (Hz)');
ylabel('DFT Magnitude');
title('Discrete Fourier Transform');
subplot(2,1,2);
plot(F,magY);
grid on;
xlim([0 2000]);
xlabel('Frequency (Hz)');
ylabel('DFT Magnitude');
title('Discrete Fourier Transform');

RESULT:
Explore and take notes.

EXERCISE
Try and remove the tone spikes from the spectra of the noisy signal.
Take Inverse DFT (IFFT) of the modified spectra.
Listen to this new time-domain signal and see if the tone noise isremoved.
Note: This is actually a very crude of way of filtering which is covered later.
Signals and Systems ©Dept. of ETE, CUET

CHITTAGONG
HITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ELECTRONICS
ELECTRONICS & TELECOMMUNICATION ENGINEERING
CHITTAGONG
CHITTAGONG-4349, BANGLADESH.
COURSE NO.: ETE 310
COURSE TITLE: DIGITAL SIGNAL PROCESSING SESSIONAL
Experiment No.
Name of Experiment: Studying z transform in MATLAB

OBJECTIVE:
1. Generate pole zero constellation in z plane.
2. Plot corresponding Frequency (Bode magnitude) response.
3. Plot impulse response and determine that the system is FIR or IIR.
4. Modify location of poles in z plane to observe the corresponding change in frequency
and impulse response.

THEORY:
The z - Transform of a general discrete time signal x(n) is defined as;

Where the complex variable z=r∠ ∠w,, with r the radius and w the angle. DTFT is a subset of z
transform when r =1. Since ‘r’ information is not present in DTFT, therefore information
about stability in discrete time can only be obtained from z transform. If pole lies inside th the
unit circle, system is stable. If pole lies outside the unit circle, system is unstable. If pole lies
at the unit circle, system is marginally stable or oscillatory. If system has FIR, it is stable. If
system is IIR, it can be stable or unstable.

PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Open M-file
file editor and write the following code:

clear all;
close all;
clc;
Num = poly([(0-(i*(pi/2))),(0+(i*(pi/2)))]);
(i*(pi/2))),(0+(i*(pi/2)))]);
Signals and Systems ©Dept. of ETE, CUET

Den = poly([-1,-1]);
Num1 = poly([j,-j]);
Den1 = poly([exp(-1),exp(-1)]);
sys1=tf(Num1,Den1,1)
figure;
subplot(3,1,1);
pzmap(sys1);
xlim([-2 2]);
ylim([-4 4]);
subplot(3,1,2);
[mag phase w]=bode(sys1);
mag=squeeze(mag);
plot(w,mag);
xlim([0 100])
subplot(3,1,3);
impulse(sys1);
H=dfilt.df1(Num,Den);
A=isfir(H)
figure;
pzmap(sys1)
grid on;

RESULT:
1. Learn the specific logical bits of the code and make notes.

2. Observe the plots.

3. Now, explain (write) in your own words the cause and effects of what you just saw.

EXERCISE:
Change the location of poles from inside the unit circle to outside and at the unit circle andobserve the
effects.
Signals and Systems ©Dept. of ETE, CUET

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY


DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING
CHITTAGONG-4349, BANGLADESH.
COURSE NO.: ETE 310
COURSE TITLE: DIGITAL SIGNAL PROCESSING SESSIONAL
Experiment No.
Name of Experiment: Designing FIR and IIR Filters using MATLAB

OBJECTIVE:
1. Create a signal vector containing two frequencies as: i) 100 Hz. and ii) 150 Hz., with
Fs = 1000 Hz.
2. Design two bandpass FIR filters with 64 coefficients and with passbands as i) 125 to
175 Hz. and ii) 75 to 125 Hz.
3. Use both filters on the created signal and observe their outputs.
4. Plot frequency responses and pole-zero constellations of both filters and note
observations.
5. Repeat steps 2 – 4 for IIR filters designed using Butterworth IIR filters.

THEORY:
1. FIR filters are Finite Impulse Response filters with no feedback, whereas IIR contains
feedback.
2. Transfer function of FIR filter does not contain any non-trivial poles. Their frequency
response is solely dependent on zero locations. IIR filters contain poles as well as
zeros.
3. As there are no poles, FIR filters cannot become unstable; however, IIR filters can
become unstable if any pole lies outside the unit circle in z-plane.
4. More number of coefficients is needed to design the desired filter in FIR than IIR.

PROCEDURE:
1. Write the following code for FIR filters:

close all;
clear all;
clc;
% Frequencies in Hz.
F1 = 100;
F2 = 150;
% Sampling Frequency in samples/sec.
Signals and Systems ©Dept. of ETE, CUET

Fs = 1000;
t = [0 : 1/Fs : 1]; % Time Vector
F = Fs*[0:length(t)-1]/length(t); % Frequency Vector
x = exp(j*2*pi*F1*t)+2*exp(j*2*pi*F2*t); % Signal Vector
bh = fir1( 64 , [125 175]/500); % filter coeffs. for bandpassing F1
bl = fir1( 64 , [75 125]/500); % filter coeffs. for bandpassing F2
[hh,wh]=freqz(bh,1,length(t),'whole'); % Frequency response for filter
1
[hl,wl]=freqz(bl,1,length(t),'whole'); % Frequency response for filter
2
% Filter operation - see filtfilt in help to learn what it does
yh = filtfilt(bh,1,x);
yl = filtfilt(bl,1,x);
% Plotting
figure,
subplot(5,1,1),plot(F,abs(fft(x)));xlim([0 Fs/2]);
title('FFT of orgianl signal');
subplot(5,1,2),plot(F,abs(hh));xlim([0 Fs/2]);
title('Frequency response of Filter One');
subplot(5,1,3),plot(F,abs(fft(yh)));xlim([0 Fs/2]);
title('FFT of filtered signal from filter one');
subplot(5,1,4),plot(F,abs(hl));xlim([0 Fs/2]);
title('Frequency response of Filter Two');
subplot(5,1,5),plot(F,abs(fft(yl)));xlim([0 Fs/2]);
title('FFT of filtered signal from filter two');
xlabel('Hz.')
% Pole Zero Constellations
[bh,ah] = eqtflength(bh,1);
[zh,ph,kh] = tf2zp(bh,ah);
[bl,al] = eqtflength(bl,1);
[zl,pl,kl] = tf2zp(bl,al);
figure,
subplot(1,2,1),zplane(bh,ah);xlim([-1.5 1.5]);ylim([-1.5 1.5]);
title('Filter One');
subplot(1,2,2),zplane(bl,al);xlim([-1.5 1.5]);ylim([-1.5 1.5]);
title('Filter Two');

2. Note the observations from frequency response and pole-zero constellation plots.
3. Now, write the code in another program for IIR filters:

close all;
clear all;
clc;
% Frequencies in Hz.
F1 = 100;
F2 = 150;
% Sampling Frequency in samples/sec.
Fs = 1000;
t = [0 : 1/Fs : 1]; % Time Vector
F = Fs*[0:length(t)-1]/length(t); % Frequency Vector
x = exp(j*2*pi*F1*t)+2*exp(j*2*pi*F2*t); % Signal Vector
[bh,ah] = butter(6,[125 175]/500);% filter coeffs. for bandpassing F1
[bl,al] = butter(6,[75 125]/500);% filter coeffs. for bandpassing F2
[hh,wh]=freqz(bh,ah,length(t),'whole'); % Frequency response for filter 1
[hl,wl]=freqz(bl,al,length(t),'whole'); % Frequency response for filter 2
% Filter operation - see filtfilt in help to learn what it does
Signals and Systems ©Dept. of ETE, CUET

yh = filtfilt(bh,ah,x);
yl = filtfilt(bl,al,x);
% Plotting
figure,
subplot(5,1,1),plot(F,abs(fft(x)));xlim([0 Fs/2]);
title('FFT of orgianl signal');
subplot(5,1,2),plot(F,abs(hh));xlim([0 Fs/2]);
title('Frequency response of Filter One');
subplot(5,1,3),plot(F,abs(fft(yh)));xlim([0 Fs/2]);
title('FFT of filtered signal from filter one');
subplot(5,1,4),plot(F,abs(hl));xlim([0 Fs/2]);
title('Frequency response of Filter Two');
subplot(5,1,5),plot(F,abs(fft(yl)));xlim([0 Fs/2]);
title('FFT of filtered signal from filter two');
xlabel('Hz.')
% Pole Zero Constellations
[bh,ah] = eqtflength(bh,ah);
[zh,ph,kh] = tf2zp(bh,ah);
[bl,al] = eqtflength(bl,al);
[zl,pl,kl] = tf2zp(bl,al);
figure,
subplot(1,2,1),zplane(bh,ah);xlim([-1.5 1.5]);ylim([-1.5 1.5]);
title('Filter One');
subplot(1,2,2),zplane(bl,al);xlim([-1.5 1.5]);ylim([-1.5 1.5]);
title('Filter Two');

4. Note the observations from frequency response, pole-zero constellation.


5. Compare plots across FIR and IIR.
Signals and Systems ©Dept. of ETE, CUET

CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY


DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING
CHITTAGONG-4349, BANGLADESH.
COURSE NO.: ETE 310
COURSE TITLE: DIGITAL SIGNAL PROCESSING SESSIONAL
Experiment No.
Name of Experiment: COMPUTATION OF POWER DENSITY
SPECTRUM OF A SEQUENCE USING MATLAB
OBJECTIVE:
1. To compute Power Density Spectrum of a sequence using MATLAB

THEORY:
By the definition of energy spectral density require that the Fourier transforms of the signals exist, that is,
that the signals are integrable/summable or square-integrable/square-summable. (Note: The integral
definition of the Fourier transform is only well-defined when the function is integrable. It is not sufficient
for a function to be simply square-integrable. In this case one would need to use the Plancherel theorem.)
An often more useful alternative is thepower spectral density(PSD), which describes how the power of a
signal or time series is distributed with frequency. Here power can be the actual physical power, or more
often, for convenience with abstract signals, can be defined as the squared value of the signal, that is, as
the actual power dissipated in a load if the signal were a voltage applied across it. This instantaneous
power (the mean or expected value of which is the average power) is then given by
P(t)=s(t)2, for a signal s(t)

PROGRAM:

clc;
clear all;
close all;
t = 0:0.001:0.6;
x = sin(2*pi*50*t)+sin(2*pi*120*t);
y = x + 2*randn(size(t));
figure,
plot(1000*t(1:50),y(1:50)) ;
title('Signal Corrupted with Zero-Mean Random Noise');
xlabel('time (milliseconds)');
Y = fft(y,512); %The power spectral density, a measurement of the energy at
various frequencies, is: Pyy = Y.* conj(Y) / 512; f = 1000*(0:256)/512;
figure, plot(f,Pyy(1:257)); title('Frequency content of y');
xlabel('frequency (Hz)');
Pyy = Y.* conj(Y) / 512;
Signals and Systems ©Dept. of ETE, CUET

f = 1000*(0:256)/512;
figure,
plot(f,Pyy(1:257));
title('Frequency content of y');
xlabel('frequency (Hz)');

RESULT:
1. Observe the plots.
2. Now, explain (write) in your own words the cause and effects of what you just saw.

You might also like