0% found this document useful (0 votes)
29 views6 pages

Digital Signal Processing Lab Assignment

This document contains MATLAB code for a digital signal processing lab assignment involving signal generation, sampling, and reconstruction. The code generates a sine wave, square wave, and impulse train. It samples the impulse train multiplied by the sine wave. It then discretizes the sampled signal and reconstructs the original signal using the sinc function. Figures are included showing the generated and reconstructed signals. The document also contains questions about how the frequency of the impulse train affects the output and whether oversampling or undersampling is observed.

Uploaded by

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

Digital Signal Processing Lab Assignment

This document contains MATLAB code for a digital signal processing lab assignment involving signal generation, sampling, and reconstruction. The code generates a sine wave, square wave, and impulse train. It samples the impulse train multiplied by the sine wave. It then discretizes the sampled signal and reconstructs the original signal using the sinc function. Figures are included showing the generated and reconstructed signals. The document also contains questions about how the frequency of the impulse train affects the output and whether oversampling or undersampling is observed.

Uploaded by

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

LAB ASSIGNMENT #02

Digital Signal Processing

CODE:
clc;
clear all;
close all;

ind=-300:300;
fsim=4000;
t=ind/fsim;
len=length(t);

fn1=50;
x1=sin(2*pi*fn1*t);
subplot(2,1,1);
plot(t,x1)
grid on;
title('Sinusoidal Wave');
xlabel('x-axis -->');
ylabel('y-axis -->');
axis([-0.1 0.1 -1.5 1.5]);
fs=500;
x2=square(2*pi*fs/2*t);
figure
subplot(2,1,1)
plot(t,x2);
grid on;
title('Square Wave');
xlabel('x-axis -->');
ylabel('y-axis -->');
axis([-0.1 0.1 -1.5 1.5]);

i=abs(diff(x2))/2;
figure
subplot(2,1,1);
plot(t(1,1:len-1),i);
grid on;
title('Impulse Train');
xlabel('x-axis -->');
ylabel('y-axis -->');
axis([-0.1 0.1 -1.5 1.5]);

y=x1(1:len-1).*i;
figure
subplot(2,1,1);
plot(t(1,1:len-1),y);
hold on;
plot(t,x1,'r');
hold off;
grid on;
title('Impulse Train * Sine Wave');
xlabel('x-axis -->');
ylabel('y-axis -->');
axis([-0.1 0.1 -1.5 1.5]);

% %%%%Discretisation

T=1/(fs*fsim);
figure
subplot(3,1,1);
stem(t(1:len-1)*T,y,'r');
grid on;
title('Discretization');
xlabel('x-axis -->');
ylabel('y-axis -->');
% axis([-0.1 0.1 -1.5 1.5]);

y_n=0;
for j=1:len-1
if (i(j)==1)
y_n=[y_n y(j)];
end
end
subplot(3,1,2);
stem(y_n(2:length(y_n)));
grid on;
title('Discretization Method 1');
xlabel('x-axis -->');
ylabel('y-axis -->');
axis([-2 62 -1.5 1.5]);

%%Reconstruction
fr=fs;
t=[0:length(y_n)-1]/fsim;
plot(t,sinc(2*pi*fr*(t-t(32))))
grid on

rec=0;

for i=1:length(y_n)
rec=rec+y_n(i)*sinc(2*pi*fr*(t-t(i)))
end
plot(t,rec)
title 'reconstruction'
grid on

FIGURES:
Impulse Train

1
y-axis -->

-1

-0.1 -0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08 0.1
x-axis -->
Discretization
1

y-axis -->
0

-1
-4 -3 -2 -1 0 1 2 3 4
x-axis --> -8
x 10
reconstruction
2

-2
0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02

QUESTIONS:
1. Provide your analysis for the changed frequency of Impulse train?
Answer: If we increase the frequency of impulse train, the output graph we get is
much closer to the original graph. Also doing so increases the samples in the
output graph.
2. Explain if you observe under, over sampling?
Answer: As I have set fs greater than fn so I observed oversampling.

Common questions

Powered by AI

Setting a low sampling frequency relative to the signal's frequency can lead to under-sampling, where important information from the original signal is lost, potentially causing aliasing. This means that the reconstructed signal may not accurately reflect the original signal, resulting in data misinterpretation and analysis errors .

Increasing the frequency of the impulse train brings the output graph closer to the original signal graph. This is because higher frequencies increase the number of samples in the output graph, which enhances the accuracy of the signal representation, closer adhering to the continuous original waveform .

Signal reconstruction is achieved by summing weighted sinc functions corresponding to each discrete sample. This cumulative approach synthesizes the original continuous signal waveform from its discrete samples. The outcome is a reconstructed signal that closely approximates the original waveform if adequately sampled .

Signal reconstruction using the sinc function involves creating a continuous-time signal from discrete samples. In this setup, the reconstructed signal is obtained by summing up sinc functions, each centered at a sample point, weighted by the sampled amplitudes. This method effectively interpolates the signal to approximate the original continuous waveform .

A sinusoidal wave is generated using the sine function, defined by parameters such as frequency (fn1 = 50 Hz) and the simulation frequency (fsim = 4000 Hz). These parameters control the oscillation speed and sampling rate, determining the wave’s periodicity and sample precision .

Oversampling occurs when the sampling frequency (fs) is set higher than the Nyquist rate (fn), which in this setup results in collecting more samples than necessary to accurately reconstruct the original signal. This can be beneficial in reducing aliasing and improving signal reconstruction fidelity but may cause increased computational load and data storage requirements .

The square wave in the assignment is represented using a periodic function of time with a frequency component derived from fs/2. It alternates between a set of predefined amplitude values, representing a non-sinusoidal waveform characterized by its shape and periodic switching between high and low states .

The impulse train serves to sample the continuous sine wave at discrete intervals. By multiplying the sine wave with the impulse train, the resulting product captures samples of the sine wave only at the instances when the impulse is non-zero. This interaction facilitates the conversion of continuous signals to discrete forms suitable for digital analysis .

'Discretization Method 1' is effective in capturing essential signal characteristics by selectively storing sample values aligned with impulse train peaks, hence reducing data size without significantly losing critical information. However, its effectiveness highly depends on the impulse train frequency and precise timing, which ensure sample adequacy to preserve original signal fidelity .

Discretization in digital signal processing serves to convert continuous signals into discrete form for digital analysis and processing. In this assignment, discretization is executed by sampling the sine wave at instances where an impulse in the train occurs. A method involving storing only sampled values when the impulse train equals one is used, thus reducing data volume while preserving necessary signal information .

You might also like