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

DSPlab 1&2

Uploaded by

shreyadhanbhar23
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 views13 pages

DSPlab 1&2

Uploaded by

shreyadhanbhar23
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
You are on page 1/ 13

COEP, Technological University

Dept. of Electronics and Telecommunication Engineering

Name: Shreya Mangesh Dhanbhar


MIS: 612207020
Branch : TY B.Tech E & TC
Course : Digital Signal Processing LAB
Course Code: ET-21006

Digital Signal Processing LAB Submission


INDEX

Sr.
List of Experiments
No

1 a) Generation of basic signals using C/ Python and MATLAB.


b) Verification of Sampling theorem
a) Program to obtain Linear Convolution of two finite length sequences and verify the
properties of linear convolution
2 b) Program to obtain Circular Convolution of two finite length sequences using FFT method
Using C/ Python and MATLAB

a) Program for computing auto correlation of two finite length sequences and obtain the
energy of the input sequence.
3 b) Program for computing cross correlation of two finite length sequences and using it to
find the delay between signals.
Using C/ Python and MATLAB

4 To perform spectral analysis of discrete signal using C/ Python and MATLAB

a) Implementation of Low Pass and High Pass FIR filter for a given sequence
5 b) Implementation of Low Pass and High Pass IIR filter for a given sequence
Using C/ Python and MATLAB

a) Implementation of Decimation Process


6 b) Implementation of Interpolation Process
Using C/ Python and MATLAB

7 Generation of Sinusoidal signal through filtering C/ Python and MATLAB

8 To perform audio/speech processing C/ Python and MATLAB

9 To perform ECG signal processing C/ Python and MATLAB

Implementing Linear Convolution and Circular Convolution in TMS320 C6748 DSP


10
Processor.

11 DFT with FFT using TMS320 C6748 DSP Processor.

Noise removal: Add noise above 3kHz and then remove; Interference Suppression using
12
400 Hz Tone using TMS320 C6748 DSP Processor.
EXPERIMENT 1(a)

AIM: Generation of basic signals using C/ Python and MATLAB.

Software: MATLAB

Code:
n = 0:20;
f= 0.1;
x_sine = sin(2*pi*f*n);
n_impulse = -10:10;
x_impulse = (n_impulse == 0);
a = 0.8;
x_exp = a.^n;
n_unit = -10:10;
x_unit = (n_unit >= 0);
T = 5;
x_sawtooth = mod(n, T);
figure;

subplot(3,2,1);
stem(n, x_sine);
xlabel('n');
ylabel('Amplitude');
title('Discrete Sine Signal');
grid on;

subplot(3,2,2);
stem(n_impulse, x_impulse);
xlabel('n');
ylabel('Amplitude');
title('Discrete Impulse Signal');
grid on;

subplot(3,2,3);
stem(n, x_exp);
xlabel('n');
ylabel('Amplitude');
title('Discrete Exponential Signal');
grid on;

subplot(3,2,4);
stem(n_unit, x_unit);
xlabel('n');
ylabel('Amplitude');
title('Discrete Unit Step Signal');
grid on;

subplot(3,2,5);
stem(n, x_sawtooth);
xlabel('n');
ylabel('Amplitude');
title('Discrete Sawtooth Signal');
grid on;
sgtitle('Basic Discrete Signals');
Output:

Observation:
Upon generating the signals:
1. Discrete Sine Signal: The sine signal oscillates periodically with a specific frequency, displaying
smooth periodic behavior.
2. Discrete Impulse Signal: The impulse signal has a value of 1 at n=0n = 0n=0 and 0 elsewhere,
acting as a basic building block in signal processing.
3. Discrete Exponential Signal: The exponential signal grows or decays depending on the
exponential rate aaa, demonstrating either an increasing or decreasing trend.
4. Discrete Unit Step Signal: The unit step signal stays at 0 for n<0n < 0n<0 and steps to 1 at n=0n
= 0n=0 and beyond, commonly used in control systems.
5. Discrete Sawtooth Signal: The sawtooth signal increases linearly and resets periodically,
representing a non-sinusoidal waveform used in various applications.

Conclusion:
The discrete signals were successfully generated and visualized, highlighting their distinct behaviors. These
signals are fundamental in various engineering fields, including signal processing and digital
communication.
EXPERIMENT 1(b)

AIM: Verification of Sampling theorem

Software: MATLAB
Code:
A = 1;
f = 5;
T = 1;

t = 0:0.001:T;
y = A * sin(2 * pi * f * t);

figure;
subplot(4, 1, 1);
plot(t, y, 'b');
title('Continuous Sine Wave');
xlabel('Time (s)');
ylabel('Amplitude');

% Case 1: fs > 2 * f (fs = 20 * f)


fs1 = 20 * f;
n1 = 0:1:T*fs1;
t_sampled1 = n1 / fs1;
y_sampled1 = A * sin(2 * pi * f * t_sampled1);

subplot(4, 1, 2);
stem(t_sampled1, y_sampled1, 'r');
title('Sampled Sine Wave (fs > 2 * f)');
xlabel('Time (s)');
ylabel('Amplitude');

% Case 2: fs = 2 * f (Nyquist rate)


fs2 = 2 * f;
n2 = 0:1:T*fs2;
t_sampled2 = n2 / fs2;
y_sampled2 = A * sin(2 * pi * f * t_sampled2);

subplot(4, 1, 3);
stem(t_sampled2, y_sampled2, 'g');
title('Sampled Sine Wave (fs = 2 * f)');
xlabel('Time (s)');
ylabel('Amplitude');

% Case 3: fs < 2 * f (fs = 0.8 * 2 * f)


fs3 = 0.8 * 2 * f;
n3 = 0:1:T*fs3;
t_sampled3 = n3 / fs3;
y_sampled3 = A * sin(2 * pi * f * t_sampled3);

subplot(4, 1, 4);
stem(t_sampled3, y_sampled3, 'm');
title('Sampled Sine Wave (fs < 2 * f)');
xlabel('Time (s)');
ylabel('Amplitude');
Output:

Observation:
When the sampling frequency is much higher than twice the signal frequency (fs > 2 * f), the sampled signal
closely follows the original wave, ensuring accurate representation. At the Nyquist rate (fs = 2 * f), the
signal is still accurately captured with minimal data points. However, when the sampling frequency is less
than twice the signal frequency (fs < 2 * f), aliasing occurs, leading to a distorted and inaccurate
representation of the original signal.
Conclusion:
We need to choose an appropriate sampling rate to avoid errors and preserve the quality of the signal.
EXPERIMENT 2(a)
AIM: Obtain Linear Convolution of two finite length sequences and verify the properties of linear
convolution

Software: MATLAB
Code:
%LINEAR CONVOLUTION
%WITHOUT USING FUNCTION
x = [7, 5, 6, 1];
h = [8, 4, 1, 6];
g = [2, 3, 5, 0];
Nx = length(x);
Nh = length(h);
Ny = Nx + Nh - 1;
y = zeros(1, Ny);
for n = 1:Ny
for k = 1:Nx
if (n - k + 1 > 0) && (n - k + 1 <= Nh)
y(n) = y(n) + x(k) * h(n - k + 1);
end
end
end
%WITH CONVOLUTION FUNCTION
z = conv(x,h);
%ASSOCIATIVE PROPERTY
xh = conv(x,h);
y1 = conv(xh,g);
hg = conv(h,g);
y2 = conv(hg,x);
disp('(x[n] * h[n]) * g[n]=');
disp(y1);
disp('x[n] * (h[n] * g[n])=');
disp(y2);
if isequal(y1, y2)
disp('Associative property is proved');
else
disp('Associative property is not proved.');
end
%COMMUTATIVE PROPERTY
hx = conv(h,x);
disp('x[n] * h[n]=');
disp(xh);
disp('h[n] * x[n]=');
disp(hx);
if isequal(xh, hx)
disp('Commutative property is proved');
else
disp('Commutative property is not proved.');

end
%DISTRIBUTIVE PROPERTY
hg = h + g;
y3 = conv(x, hg);
xg = conv(x, g);
y4 = xh + xg;
disp('Result of x[n] * (h[n] + g[n])=');
disp(y3);
disp('Result of x[n] * h[n] + x[n] * g[n]=');
disp(y4);
if isequal(y3, y4)
disp('Distributive property is proved: x[n] * (h[n] + g[n]) = x[n] * h[n] + x[n] * g[n]');
else
disp('Distributive property is not proved.');
end

Output:
(x[n] * h[n]) * g[n]=
112 304 634 723 692 589 323 203 30 0

x[n] * (h[n] * g[n])=


112 304 634 723 692 589 323 203 30 0

Associative property is proved


x[n] * h[n]=
56 68 75 79 40 37 6

h[n] * x[n]=
56 68 75 79 40 37 6

Commutative property is proved


Result of x[n] * (h[n] + g[n])=
70 99 137 124 73 42 6

Result of x[n] * h[n] + x[n] * g[n]=


70 99 137 124 73 42 6
Distributive property is proved: x[n] * (h[n] + g[n]) = x[n] * h[n] + x[n] * g[n]

Observation:
The convolution of x[n] and h[n] using MATLAB's conv function produces a sequence that represents the
linear combination of the input sequences. The result is consistent with the expected length, Nx + Nh - 1,
and correctly represents the overlapping and shifting of the two sequences.

Conclusion:
MATLAB's conv function accurately performs linear convolution and upholds the associative,
commutative, and distributive properties.
EXPERIMENT 2(b)

AIM: Obtain Circular Convolution of two finite length sequences using FFT method
Software: MATLAB
Code:
x = [7, 5, 6, 1];
h = [8, 4, 1, 6];

N = max(length(x), length(h));

x_padded = [x, zeros(1, N-length(x))];


h_padded = [h, zeros(1, N-length(h))];

X = fft(x_padded);
H = fft(h_padded);

Y = X .* H;
y_circular = ifft(Y);

disp('Circular Convolution result using FFT:');


disp(y_circular);

Output:
Circular Convolution result using FFT:
96 105 81 79
Observation:
The output sequence y_circular represents the circular convolution of the two input sequences, and it
matches what is expected based on the theory of circular convolution.
Conclusion:
The circular convolution of two sequences was efficiently calculated using the FFT method in MATLAB.
This technique utilizes FFT and inverse FFT for fast computation, making it ideal for tasks involving
periodic signal processing.

You might also like