Sie sind auf Seite 1von 10

MUDDASSAR HUSSAIN

Student ID # 6597

ADSP LAB # 5 & 6


Submitted By :
Registration No. :

MUDDASSAR HUSSAIN
6597

Date: 12-11-2014

Lab # 5:
Sampling Theorem
Summary:
This lab gave an insight in the analysis of signals after sampling it on different sampling
frequencies. In this analysis we also check the aliasing effect. At the end we reconstruct the
signal from its samples.
In signal processing, sampling is the reduction of a continuous signal to a discrete signal. A
common example is the conversion of a sound wave (a continuous signal) to a sequence of
samples (a discrete-time signal). A sample refers to a value or set of values at a point in time
and/or space. A sampler is a subsystem or operation that extracts samples from a continuous
signal.
The sampling frequency or sampling rate, fs, is the average number of samples obtained in one
second (samples per second), thus fs = 1/T.
Reconstructing a continuous function from samples is done by interpolation algorithms.
The WhittakerShannon interpolation formula is mathematically equivalent to an ideallowpass
filter whose input is a sequence of Dirac delta functions that are modulated (multiplied) by the
sample values. When the time interval between adjacent samples is a constant (T), the sequence
of delta functions is called a Dirac comb. Mathematically, the modulated Dirac comb is
equivalent to the product of the comb function with s(t). That purely mathematical abstraction is
sometimes referred to as impulse sampling.
In practice, the continuous signal is sampled using an analog-to-digital converter (ADC), a
device with various physical limitations. This results in deviations from the theoretically perfect
reconstruction, collectively referred to as distortion.

Lab Task:

MUDDASSAR HUSSAIN

Student ID # 6597

At fs =50
t= 0:0.0005:1;
fm=25;
xa = cos(2*pi*fm*t);
subplot(2,2,1)
plot(t,xa);grid
xlabel('Time, msec');ylabel('Amplitude');
title('Continuous-time signal x_{a}(t)');
fs=50;
T=1/fs;
n=0:T:1;
xs = cos(2*pi*fm*n);
k = 0:length(n)-1;
subplot(2,2,2)
stem(k,xs); grid
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal x[n]')
xz = sinc(pi*n/T);
xc = conv(xz,xs);
subplot(2,2,3);
plot(xc);grid;
xlabel('Time, msec');ylabel('Amplitude');
title('Reconstructed continuous-time signal y_{a}(t)');
xf = freqz(xs);
subplot(2,2,4);
stem(abs(xf));
xlabel('Freq Scale');ylabel('Amplitude');
title('Frequency Scale of Sampled Signal ');

MUDDASSAR HUSSAIN

Student ID # 6597
At fs =100

t= 0:0.0005:1;
fm=25;
xa = cos(2*pi*fm*t);
subplot(2,2,1)
plot(t,xa);grid
xlabel('Time, msec');ylabel('Amplitude');
title('Continuous-time signal x_{a}(t)');
fs=100;
T=1/fs;
n=0:T:1;
xs = cos(2*pi*fm*n);
k = 0:length(n)-1;
subplot(2,2,2)
stem(k,xs); grid
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal x[n]')
xz = sinc(pi*n/T);
xc = conv(xz,xs);
subplot(2,2,3);
plot(xc);grid;
xlabel('Time, msec');ylabel('Amplitude');
title('Reconstructed continuous-time signal y_{a}(t)');
xf = freqz(xs);
subplot(2,2,4);
stem(abs(xf));
xlabel('Freq Scale');ylabel('Amplitude');
title('Frequency Scale of Sampled Signal ');

y(n)+0.25y(n-1)+5y(n-2)+y(n-3)+0.2y(n-4) = 0.1x(n-4)+0.5x(n-3)+3x(n-2)+x(n-1)+0.7x(n)

MUDDASSAR HUSSAIN

Student ID # 6597
At fs =200

t= 0:0.0005:1;
fm=25;
xa = cos(2*pi*fm*t);
subplot(2,2,1)
plot(t,xa);grid
xlabel('Time, msec');ylabel('Amplitude');
title('Continuous-time signal x_{a}(t)');
fs=200;
T=1/fs;
n=0:T:1;
xs = cos(2*pi*fm*n);
k = 0:length(n)-1;
subplot(2,2,2)
stem(k,xs); grid
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal x[n]')
xz = sinc(pi*n/T);
xc = conv(xz,xs);
subplot(2,2,3);
plot(xc);grid;
xlabel('Time, msec');ylabel('Amplitude');
title('Reconstructed continuous-time signal y_{a}(t)');
xf = freqz(xs);
subplot(2,2,4);
stem(abs(xf));
xlabel('Freq Scale');ylabel('Amplitude');
title('Frequency Scale of Sampled Signal ');

MUDDASSAR HUSSAIN

Student ID # 6597

Lab # 6:
Discrete Fourier Transform
Summary:
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. It can be said to convert the sampled
function from its original domain (often time or position along a line) to the frequency domain.
The DFT is the most important discrete transform, used to perform Fourier analysis in many
practical applications. In digital signal processing, the function is any quantity or signal that
varies over time, such as the pressure of a sound wave, a radio signal, or
daily temperature readings, sampled over a finite time interval (often defined by a window
function). In image processing, the samples can be the values of pixelsalong a row or column of
a raster image. The DFT is also used to efficiently solve partial differential equations, and to
perform other operations such as convolutions or multiplying large integers.
This lab provides a good practice of performing Fourier analysis by using DFT. & we observe
the magnitude & angle of DFT of different signals. We prove two properties of DFT also here
i.e., Linearity & Shifting Theorem. One more thing that is provided by this lab is the scaling of
axis according to frequency.

Lab Task:
Part (a & b)
t=0:7;
fs=8000;
T=1/8000;
x1=sin(2*pi*1000*t*T);
x2=0.5*sin((2*pi*2000*t*T)+3*pi/4);
x=x1+x2;
subplot(2,3,1)
plot(t,x)
xlabel('Time index t');ylabel('Amplitude');
title('Input Signal');
xk=zeros(1,8)
for k=0:7
for n=0:7
xk(k+1)=xk(k+1)+(x(n+1)*exp(-j*2*pi*k*n/8));

MUDDASSAR HUSSAIN
end
end
xkmag=abs(xk)
subplot(2,3,2)
stem(xkmag)
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal Xin[n]');
xkp=angle(xk)
subplot(2,3,3)
stem(xkp)
xlabel('Time index n');ylabel('Phase');
title('Discrete-time signal Xin[n]');
xkmags=fftshift(xkmag)
fs=-4*(fs/8):fs/8:3*(fs/8);
subplot(2,3,4)
stem(fs,xkmags)
xlabel('freq scale n');ylabel('Amplitude');
title('Discrete-time signal Xin[n]');
xkps=fftshift(xkp)
fs=-4*(fs/8):fs/8:3*(fs/8);
subplot(2,3,5)
stem(fs,xkps)
ylabel('freq shifted angle x[k]')

Student ID # 6597

MUDDASSAR HUSSAIN

Student ID # 6597
Part (c)

f1=1000;
f2=2000;
fs=8000;
t=-0.005:1/1000000:0.001;
x1=sin(2*pi*f1*t);
x2=0.5*sin(2*pi*2000*t+3*pi/4);
x3=x1+x2;
subplot(3,3,1);
plot(t,x3);
xlabel('Time index t');ylabel('Amplitude');
title('Input Signal');
T = 1/fs;
n = 0:T:0.001;
x4=sin(2*pi*f1*n);
x5=0.5*sin(2*pi*2000*n+3*pi/4);
x6=x4+x5;
k = 0:length(n)-1;
subplot(3,3,2)
stem(k,x6); grid
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal Xin[n]');
N=length(x6)-1;
n1=0*fs/8:fs/8:7*fs/8;
x7=fft(x6,8);
subplot(3,3,3)
stem(n1,abs(x7)); grid
xlabel('freq scale n');ylabel('Amplitude');
title('Discrete-time signal Xin[n]');
subplot(3,3,4)
stem(n1,angle(x7)); grid
xlabel('freq scale');ylabel('angle');
title('freq scale Xin[n]');

n1=0*fs/8:fs/8:7*fs/8;
x7=fft(x4,8);
subplot(3,3,5)
stem(n1,abs(x7)); grid
xlabel('freq scale n');ylabel('Amplitude');
title('freq scale X4[n]');
subplot(3,3,6)
stem(n1,angle(x7)); grid

MUDDASSAR HUSSAIN
xlabel('freq scale');ylabel('angle');
title('freq scale X4[n]');
n1=0*fs/8:fs/8:7*fs/8;
x8=fft(x5,8);
subplot(3,3,7)
stem(n1,abs(x8)); grid
xlabel('freq scale n');ylabel('Amplitude');
title('freq scale X5[n]');
subplot(3,3,8)
stem(n1,angle(x8)); grid
xlabel('freq scale');ylabel('angle');
title('freq scale X5{n]');
subplot(3,3,9)
x9=x7+x8;
stem(n1,abs(x9)); grid
xlabel('freq scale');ylabel('angle');
title('freq scale summition of {n]');

Student ID # 6597

MUDDASSAR HUSSAIN

Student ID # 6597
Part (d)

f1=1000;
f2=2000;
fs=8000;
t=-0.005:1/1000000:0.001;
x1=sin(2*pi*f1*t);
x2=0.5*sin(2*pi*2000*t+3*pi/4);
x3=x1+x2;
subplot(2,3,1);
plot(t,x3);
xlabel('Time index t');ylabel('Amplitude');
title('Input Signal');
T = 1/fs;
n = 0:T:0.001;
x4=sin(2*pi*f1*n);
x5=0.5*sin(2*pi*2000*n+3*pi/4);
x6=x4+x5;
k = 1:length(n);
subplot(2,3,2)
stem(k,x6); grid
xlabel('Time index n');ylabel('Amplitude');
title('Discrete-time signal Xin[n]');
N=length(x6)-1;
n1=0*fs/8:fs/8:7*fs/8;
x7=fft(x6,8);
subplot(2,3,3)
stem(n1,abs(x7)); grid
xlabel('freq scale n');ylabel('Amplitude');
title('Discrete-time signal Xin[n]');
subplot(2,3,4)
stem(n1,angle(x7)); grid
xlabel('freq scale');ylabel('angle');
title('freq scale Xin[n]');
x8 = exp((j*2*pi)/N).*x7;
subplot(2,3,5)
stem(n1,abs(x8)); grid
xlabel('freq scale n');ylabel('Amplitude');
title('Discrete-time signal Xin[n]');
subplot(2,3,6)
stem(n1,angle(x8)); grid
xlabel('freq scale');ylabel('angle');
title('freq scale Xin[n]');

MUDDASSAR HUSSAIN

Student ID # 6597

Das könnte Ihnen auch gefallen