Sampling and different methods of reconstruction  a MATLAB experiment for Purdue ECE 301,
by Prof. ChihChun Wang.
Preparation (different from the previous MATLAB experiments)
1. Download the different wav files
x1.wav
(Save it as “x1.wav”.)
2. Download the following m files:
ece301conv.m
,
ece301_sampler.m
,
ece301_ZOH.m
,
ece301_Lin.m
,
ece301_Opt.m
.
3. Open MATLAB and change the directory to where you have saved the previous files.
4. Enter the following commands
duration=8;
f_sample=44100;
t=(((04)*f_sample+0.5):((duration4)*f_sample0.5))/f_sample;
Basic operations:
1. If you want to construct a sin wave with frequency 440Hz, use the following commands:
f=440;
s=sin(2*pi*f*t);
If you want to construct a sinc function sinc(t), use the command:
sc=sin(pi*t)./(pi*t);
Note: every time you do vector multiplication or division, you need to add a period “.” before the “*” and
“/” operator.
2. The convolution of two signals x1 and x2 can be achieved by the following command
y=ece301conv(x1,x2);
3. If you would like to sample a continuoustime signal x with sampling period 0.02 sec, then use the
following command.
x=sin(t);
T=0.2;
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document[xn, sampling_index, sampling_locations]=ece301_sampler(x,T);
If you would like to plot the new discrete time signal x[n], use the following command
stem(sampling_index, xn);
xlabel('n');
ylabel('x[n]');
If you would like to place the sampled values in their corresponding positions, use the following
command
plot(sampling_locations, xn, 'o');
xlabel('t (sec)');
ylabel('x(nT)');
Remark: Notice the change of the timeaxis.
You can also compare the continuoustime signal and the sampled values by
plot(t, x, sampling_locations, xn, 'ro');
xlabel('t (sec)');
legend('x(t)', 'x(nT)');
Requirement:
You are asked to plot several figures. Print all the figures for each objective. Your HW
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '06
 V."Ragu"Balakrishnan
 Signal Processing, following commands

Click to edit the document details