Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
23 views11 pages

EEE 304 Lab2

Uploaded by

Sameen
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)
23 views11 pages

EEE 304 Lab2

Uploaded by

Sameen
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/ 11

EEE 304, LAB 2

The objective of this sequence of laboratory exercises is to explore a few fundamental


problems arising in Sampling and Reconstruction.

1. Sampling Theory
Suppose we sample a signal, such as the one in Figure 1, which is band-limited to frequencies
between 0 Hz and f Hz. If we want to reconstruct the signal later, we must ensure that the
n

sample rate, fs, is strictly greater than 2*fn. A signal sampled at fs = 2*fn is said to be Nyquist
sampled, and fs = 2*fn is called the Nyquist Rate. This is a consequence of the Nyquist-
Shannon Sampling Theorem which states that in order to perfectly capture or reconstruct a
signal after sampling it, the sampling rate must be at least twice that of the highest
frequency (fn ) in the signal band.
Note that information may be lost if a signal is sampled exactly at the Nyquist frequency. For
example, the sine wave in Figure 1 has a frequency of 1/2 Hz. The Nyquist Rate is therefore 1
Hz. If we sample the sine wave at a rate of 1 Hz, say at t=0, t=1, t=2, and so on, all the
sample values will be 0. The signal will look is if it were identically 0, and no reconstruction
method will be able to recreate the 1/2 Hz sine wave. This is why fs must be strictly greater
than 2*fn.

Figure 1: Sine Wave Signal.

2. Reconstruction Theory
The reconstruction of a signal is implemented by applying a low pass filter to the sampled
signal. As an example, consider person 'A' speaking into a telephone. Typical human voice
signals have between 300 hz - 3.4 Khz signals. A sampling rate of 8 Khz is more than sufficient
to accurately capture all the signals present in person 'A's voice. The signal is digitized and
sent over a communication protocol to person 'B'. A low pass filter filters the 8 Khz signal back
to 0.3 - 3.4 Khz and accurate reconstruction of person 'A's voice is heard through the speaker
by person 'B'.
3. Frequency-Magnitude characteristics of a signal
The frequency-magnitude of discrete signal is described by the Discrete Fourier Transform
(DFT). In Matlab, the DFT is done be the command 'fft'.
Use the 'help fft' in Matlab to learn how to use it. You may also refer to the Lab 1 document.
The relationship between the analog frequency, w, and digital frequency, f, is defined by
w = 2nf/fs
Where, fs is the sampling frequency.
Therefore, w =2n corresponds to f=fs. For 100 points fft, these 100 points occupy the range,
[0, 2 n] evenly. The frequency interval between 2 consecutive points is fs/(100-1). The sample
code shows a way to plot the double-sided frequency-magnitude plot.
%% let's start with a clean slate
clear % clears all workspace variables
close all % closes all windows and figures

%% create the sine wave


fs=1000; % sample frequency 1000Hz
t=0:1/fs:0.2; % the duration: 0.2 seconds
fn=50; % single frequency 50Hz
y=sin(2*pi*fn*t); % the sine wave
figure % create a figure
plot(t,y); % plot the wave
title('the sine wave'); % title of the figure
xlabel('Time (second)'); % the label of x-axis
ylabel('Magnitude'); % the label of y-axis
pause
%% plot the frequency response. Double sided spectrum
no_pts = (length(y)); % create the no. of points of FFT
Y = fft(y)/(no_pts); % generate FFT and divide by no_pts to normalize it ;
f = (0:no_pts-1)*fs/no_pts; % shift to be double-sided spectrum figure
plot( f,abs(Y), 'b' ), %plot positive frequency
ylabel('|Y(f)|'); xlabel('f (Hz)')
figure
plot( max(f)/2-f, fftshift(abs(Y)) ) % fftshift generates the shifted amplitudes
4. Some Derivations: Continuous Fourier Transform
interpretation of the Discrete Fourier transform (DFT)
the Fast Fourier Transform (FFT) and the Discrete Time
Fourier Transform (DTFT)
The DTFT is a discrete-time transform defined for an infinite sequence of numbers, as
follows.
𝑋(𝑒 𝑗Ω ) = ∑∞
−∞ 𝑥(𝑛)𝑒
−𝑗Ω𝑛

The DTFT is periodic with period 2𝜋.


The DFT is a discrete-time transform defined for a finite sequence of N numbers, as follows.
2𝜋
−𝑗 𝑘𝑛
𝑋(𝑘) = ∑𝑁−1
𝑛=0 𝑥(𝑛)𝑒 𝑁
The term FFT is used to signify a specific method to compute the DFT in an efficient manner. While a
transform in its own right, the DFT/FFT can be interpreted in terms of the CT-Fourier transform for a
sampled signal x(t).

4.1 General aperiodic case


Let us consider a signal x(t), sampled at the time instants nT, n = 0,1,…N-1, and suppose that
the signal is 0 outside the sampled interval [0, (N-1)T]. The Fourier transform of this signal is
 ( N −1)T

 x(t )e  x(t )e
− jwt − jwt
X ( jw) = dt = dt
− 0

First, in a naïve approach, let us approximate the integral by an Euler discretization, whereby
the integrand is taken as piecewise constant.
( N −1)T N −1

 x(t )e dt   x(nT )e T
− jwt − jwnT
X ( jw) =
0 n =0

Let us consider now a sampled version of the Fourier transform at the frequencies
2
w = kw0 = k , where k=0,1,…,N-1. Then,
TN
N −1 k 2 N −1 2
−j nT −j kn
X ( jkw0 )   x(nT )e NT
T = T  x(nT )e N

n =0 n =0

Thus,

F{x} |w= kw0  FFT {x(nT )}T

This approximation is valid as long as the integrand approximation by a piecewise constant


function is reasonable. This implies that k must be small and x(t) should not change
significantly inside any sampling interval of length T.
In a more precise formulation, the sampled signal has a Fourier transform

1 2 1
X s ( jw) =
2
X ( jw) *
T
  (w − kw ) = T  X ( j(w − kw ))
k
s
k
s

2
where, as usual, ws = . This is the familiar form of the sampled signal Fourier transform
T
as a summation of shifted replicas of the signal Fourier transform. Of course, aliasing effects
will occur if X(jw) extends beyond half the sampling frequency. On the other hand, using the
Fourier transform definition on the sampled signal we find

   
X s ( jw) = F  x(t )  (t − nT ) =   x(t )  (t − nT )e − jwt dt
 k   n 
 
=   x(nT ) (t − nT )e − jwnT dt =  x(nT )e − jwnT   (t − nT )dt
n  n

=  x(nT )e − jwnT

2
Again, evaluating this transform at a discrete set of frequencies w = kw0 = k , we get
TN
2
 2  − j kn
X s  jk  =  x(nT )e N = FFT {x(nT )}
 TN  n
In other words, the FFT of the sampled signal is equal to the Fourier transform of the sampled
signal evaluated at the frequencies kw0, in the interval [0, ws]. This means that the FFT will
be symmetric about the point ws/2. It will also be approximately equal to X(jw)/T, (at the
corresponding discrete frequencies in the interval [0, ws/2]) as long as any aliasing effects are
small.

(Note: The symmetry of the FFT is the reason why only the first half of the FFT points are
shown in the plots.)

4.2 The Periodic Case


We assume that the period is NT. Then the CFT is found by computing the Fourier Series
expansion
1 2𝜋
𝑋(𝑗𝑤) = 2𝜋 ∑𝑘 𝑎𝑘 𝛿(𝑤 − 𝑘𝑤𝑠 ), where, 𝑎𝑘 = ∫ 𝑥(𝑡)𝑒 −𝑗𝑤𝑜 𝑡 𝑑𝑡 ; 𝑤𝑜 =
𝑁𝑇 <𝑁𝑇> 𝑁𝑇
The DTFT is also found by computing the DFS expansion first
1 2𝜋
𝑋(𝑗𝑒 𝑗Ω ) = 2𝜋 ∑𝑘 𝑏𝑘 𝛿(Ω − 𝑘Ω𝑜 ), where, 𝑏𝑘 = ∑<𝑁> 𝑥(𝑛)𝑒 −𝑗𝑘Ωο 𝑛 ; Ω𝑜 =
𝑁 𝑁𝑇
Notice that 𝑥(𝑛) = 𝑥(𝑛𝑇), where the first is the DT sequence and the second is the CT
function evaluated at nT. It follows that 𝑏𝑘 ≃ 𝑎𝑘 , being the discretization of the FS integral.
Also, for the DFT is 𝑋𝐷𝐹𝑇 (𝑘) = ∑𝑁 𝑥(𝑛)𝑒 −𝑗𝑘Ωo 𝑛 = 𝑁𝑏𝑘 . If, in addition, the signal is bandlimited
and its maximum frequency is smaller than n/T, then there is no aliasing and 𝑎𝑘 = 𝑏𝑘 .

4.3 Derivation of Fourier Transform of a Windowed Sinusoid


The signal under consideration is y(t) = sin(w0t), for t in [0,Tmax]. Consequently,

1 
F{sin( w0t ) pulse[ 0,Tmax ] (t )} =  (w − w0 ) −  (w + w0 )*  2 sin( wTmax / 2) e − jwTmax / 2 
2 j  w 
1  sin(( w − w0 )Tmax / 2) − j ( w− w0 )Tmax / 2 sin(( w + w0 )Tmax / 2) − j ( w+ w0 )Tmax / 2 
=  e − e 
j w − w0 w + w0 
This expression is used to compare the FFT-computed transform that may (does) include
aliasing effects with its theoretical value as the sampling interval approaches zero.

4.4 Comparison of the windowed sinusoid CFT and FFT


The following code implements the previously outlined theory.
fs=44100; no_pts=8192;
t=([0:no_pts-1]')/fs;
y1=sin(2*pi*1000*t);
figure;
plot(t,y1);
xlabel('t (second)')
ylabel('y(t)')
axis([0,.004,-1.2,1.2]) % constrain axis so you can actually see the wave
sound(y1,fs); % play sound using windows driver.
%%
% Check the frequency domain signal. fr is the frequency vector and f1 is the
magnitude of F{y1}.
fr=([0:no_pts-1]')/no_pts*fs; %in Hz
fr=fr(1:no_pts/2); % single-sided spectrum
f1=abs(fft(y1)); % compute fft
f1=f1(1:no_pts/2)/fs;
%%
% F is the continuous time Fourier. (See derivation notes.) Notice the small
% amount of aliasing due to the fact that the truncated sinusoid is not bandlimited.
frp=fr*2*pi;tmax=max(t);
F1=1/1i*sin((frp-1000*2*pi)*tmax/2).*exp(-1i*(frp-1000*2*pi)*tmax/2)./(frp-
1000*2*pi); % li = i, the imaginary part symbol
F2=1/1i*sin((frp+1000*2*pi)*tmax/2).*exp(-
1i*(frp+1000*2*pi)*tmax/2)./(frp+1000*2*pi);
F=abs(F1-F2); % magnitude
figure;
plot(fr, F, fr, f1) % compare the continuous time Fourier with FFT, linear scale
axis([0,1500,0,0.09]) % constrain axis so you can actually see the pulse
xlabel('f (Hz)')
ylabel('|Y(f)|')
legend('Continuous-time FT', 'FFT')
figure;
loglog(fr,F,fr,f1); % compare the continuous time Fourier with FFT, log-log scale
xlabel('f (Hz)')
ylabel('|Y(f)|')
legend('Continuous-time FT', 'FFT')

4.5. Aliasing Effects


Now we sample the same sinusoid (1 kHz) in Section 5 at a lower sampling rate to observe the
aliasing effects. You must have all the variables from the code in Section 5 in the MATLAB
workspace for this to work. Also observe the impact of zero-order hold (ZOH) signal
reconstruction on the quality of the output signal.
close all;
%%
% Sample the sinusoid at 44/4 kHz. Compare the two output and play the sound.
% This may still sound OK because of the internal filtering of the soundcard.
a=4; t_a=([0:no_pts/a-1]')/fs*a;
y_a=sin(2*pi*1000*t_a);
figure
plot(t,y1,t_a,y_a);
xlabel('t (second)')
ylabel('y(t)')
legend('fs = 44kHz', 'fs = 11kHz')
axis([0,0.004,-1.2,1.2]);
display('sampled at 11kHz,played at 11kHz')
sound(y_a,fs/a); % specify sampling rate for the soundcard
pause(2) % pause for 2 sec to separate from the next sound command
%%
% Check the frequency domain signal. Notice that the replicas of F{y_a} are
% now in the audible range (not shown).
fr_a=([0:no_pts/a-1]')/no_pts*a*fs/a;
fr_a=fr_a(1:no_pts/a/2);
f_a=abs(fft(y_a));
f_a=f_a(1:no_pts/a/2)/fs*a;
figure
loglog(fr,F,fr,f1,fr_a,f_a); % log-log scale
xlabel('f (Hz)')
ylabel('|Y(f)|')
legend('Continuous-time FT', 'FFT (fs=44kHz)', 'FFT (fs=11kHz)')
%%
% Signal reconstruction:
% Use the interp1 function to get the ZOH (zero-order hold) version of the signal at
44 kHz.
% The ZOH version is how the signal would sound with a 44 kHz D/A converter
% soundcard
% Its difference from the original is significant in both the time and
% frequency domain and its reproduction is quite poor.
y_n = interp1(t_a,y_a,t,'nearest','extrap');
f_n=abs(fft(y_n));
f_n=f_n(1:no_pts/2)/fs;
figure
plot(t,y1,t,y_n);
axis([0,0.004,-1.2,1.2]);
xlabel('t (second)')
ylabel('y(t)')
legend('fs = 44kHz', 'fs = 11kHz reconstructed at 44kHz using ZOH')
figure
loglog(fr,F,fr,f1,fr,f_n);
xlabel('f (Hz)')
ylabel('|y(f)|')
legend('Continuous-time FT', 'FFT (fs = 44kHz)', 'FFT (fs = 11kHz reconstructed at
44kHz using ZOH)')
display('sampled at 44kHz,played at 44kHz')
sound(y1,fs);
pause(2)
display('sampled at 11kHz,played at 44kHz')
sound(y_n,fs);

4.6 Upsampling
Given a discrete-time signal y(n), the upsampled signal (by a) is defined as the signal z(n)
such that
𝑦(𝑘) 𝑖𝑓 𝑛 = 𝑎𝑘
𝑧(𝑛) = {
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Equivalently, we may think of z(n) as the signal produced by sampling the continuous time
𝑇
signal y(t) with the impulse train 𝑝𝑢(𝑡) = ∑𝑏𝑛 𝛿(𝑡 − 𝑛 ), where 𝑏𝑛 = 1 if n/a is an integer and 0
𝑎
otherwise. Clearly, the upsampling impulse train is identical to the original delta train 𝑝𝑢(𝑡) =
𝑇
∑𝑏𝑛 𝛿(𝑡 − 𝑛 ) and, therefore, the continuous-time sampled signals y(t)p(t) and y(t)pu(t) are
𝑎
the same, and have the same Fourier transforms. The latter, however, has a smaller sampling
time (larger sampling frequency), implying that the FFT of the discrete-time sequence will
contain several replicas of F{y}. The upsampling process does not create any new information
about the time signal but allows for the implementation of better low-pass filters in discrete
time. Instead of using ZOH to reconstruct the signal as shown in the previous section, the
following MATLAB code use upsampling to “interpolate” the values of the low rate signal and
convert it to a high rate signal, and then pass the signal through a low pass filter to recover
the original signal. This does not overcome any aliasing effects that occurred at sampling but
improves the reproduction by reducing the undesirable properties of the low rate ZOH. Note
this implementation does require a better high-rate D/A converter. In the MATLAB code
below, a digital filter is implemented by approximating the impulse response of an ideal low-
pass filter. Once again, variables from the previous experiments must be present in MATLAB
workspace for this script to run correctly.
close all;
%%
% Generate an “Upsampled” version of the low-rate signal at 44 kHz.
% zero-fill the added sampling points
% The upsampled signal contains several replicas of the original Fourier
% transform within the sampling frequency and it is not an approximation
% of the original signal.
y_u=y1*0;k=1:a:no_pts;y_u(k)=y_a;
f_u=abs(fft(y_u));
f_u=f_u(1:no_pts/2)/fs*a;
figure
plot(t,y1,t,y_u);axis([0,0.004,-1.2,1.2])
xlabel('t (second)')
legend('y(t)','y(t) upsampled')
figure
plot(fr,f1,fr,f_u, '--'); % linear scale
xlabel('f (Hz)')
ylabel('|Y(f)|')
legend('FFT (fs = 44kHz)', 'FFT (fs = 11kHz, upsampled)')
%%
% However, the original signal can be "recovered” after low-pass filtering.
% Here, the filter is defined in terms of its impulse response and the output
% is computed as a convolution sum. Notice that the impulse response HS is 1999
% points long yielding a 999 points delay in the sound reproduction. This is
% significant but not necessarily impractical.
% The low pass filter is a sinc function, whose frequnce response is an
% ideal lowpass filter with cutoff frequency of 3kHz.
hs=sin(3000*2*pi*t)/pi./t; i=1000:-1:2;
% make it symmetric, sinc(0)=sin(2*pi*f*t)/(2*pi*f*t)=1, so
% sin(2*pi*f*0)/(pi*0)=2*f
HS=[hs(i);3000*2;hs(2:1000)]*a/fs;
figure
plot(HS); % see the response of the filter designed
xlabel('t')
ylabel('h(t)')
y_f=conv(HS,y_u); % compute the filtered signal
%figure;
%plot(y_f) % uncomment to see the filtered signal
y_f=y_f(1000:999+no_pts); % extract the middle part of the signal
figure
plot(t,y1,t,y_f);axis([0,0.004,-1.2,1.2])
xlabel('t (second)')
legend('y(t)','y(t) upsampled-filtered')
f_f=abs(fft(y_f));f_f=f_f(1:no_pts/2)/fs; % get fft of y_u
figure
loglog(fr,f1,fr,f_f); % log-log scale
xlabel('f (Hz)')
ylabel('|Y(f)|')
legend('FFT (fs = 44kHz)', 'FFT (fs = 11kHz, upsampled-filtered)')
disp('sampled at 44kHz, played at 44kHz');
sound(y1,fs);
pause(2)
disp('sampled at 11kHz, upsampled-filtered, played at 44kHz');
sound(y_f,fs);

4.7 Equalizing
Equalizers are often used in audio equipment to amplify (or attenuate) frequency bands in an
effort to improve the quality of reproduction of the original signal. Their objective is to
cancel (or invert) the audio signal distortion caused by equipment limitations (amplifier,
speaker, media) or the environment where the signal is reproduced. The following MATLAB
code uses digital low-pass filters to implement a “frequency equalizer.” The test signal is the
standard Windows sound “Tada.” The MATLAB program loads the sound (make sure its copy is
in the MATLAB working directory) and filters it with three different low-pass filters. Then, by
taking different linear combinations of the resulting signals we can amplify or attenuate the
energy of the signal in the desired frequency band(s). When you run the program, it will ask
for equalizer coefficients that it uses to scale up the signal components in four frequency
bands. Enter a vector such as [1 100 100 1] will scale the signal in the middle two frequency
bands by 100, and it is essentially a bandpass filter.

% Equalization
clear all;close all;clc;
[y,f]= audioread('tada.wav');
y=y(:,1); % keep only one channel
% plot fft of the sound signal
ly=length(y); % no of points in the data
ty=([1:ly]'-1)/f;
w=([1:ly]'-1)/ly*f;w=w(1:ly/2); %in Hz, single-sided spectrum
fy=abs(fft(y));fy=fy(1:ly/2)/f; % FFT of original signal
% define 3 999-point lowpass filters
i=2:500;i_=500:-1:2; L=500:499+ly;
hs1=sin(700*2*pi*ty)/pi./ty;HS1=[hs1(i_);700*2;hs1(i)]/f; % cutoff freq= 700Hz
hs2=sin(2000*2*pi*ty)/pi./ty;HS2=[hs2(i_);2000*2;hs2(i)]/f; % cutoff freq = 2kHz
hs3=sin(5000*2*pi*ty)/pi./ty;HS3=[hs3(i_);5000*2;hs3(i)]/f; % cutoff freq = 5kHz
z1=conv(HS1,y);z1=z1(L);
z2=conv(HS2,y);z2=z2(L);
z3=conv(HS3,y);z3=z3(L);
done=0;
coef=input('enter equalization coefficients [low, mid-low, mid-hi, hi]: ');
if isempty(coef),coef=[1 1 1 1];end
% extract the signal in each of the frequency band: 0~700, 700~2k,
% 2k~5k, >5k, multiply each with the corresponding equalizer coeffs
% entered and add up the 3 scaled signal
yx=[z1 z2-z1 z3-z2 y-z3]*coef';
fx=abs(fft(yx));fx=fx(1:ly/2)/f;
figure
loglog(w, fy, w,fx, '--');
legend('orignal', 'equalized signal')
xlabel('f (Hz)');
ylabel('|Y(f)|');
disp('original')
soundsc(y,f)
pause(2)
disp('equalized')
soundsc(yx,f)
5. Lab 2 Assignment

#0. Write an overview of your results.


#1. Implement sampling and reconstruction in Simulink with the following specifications.
• x(t) is a sinusoid with 70Hz with amplitude 1 with sample period 1/20000s for 1s time interval
• Zero-Order-Hold (ZOH) sampling
• Sampling frequencies: 80Hz, 400Hz, and 1000Hz. Changed by applying the corresponding sampling times
in second in the zero-order hold sampling time block.

Build a SIMULINK model to sample x(t) with ZOH sampling method with different sampling frequencies listed in the
specifications. Output the data generated to the MATLAB workspace. Include screenshot of your SIMULINK block
diagram.

Note: You will need the following SIMULINK blocks: “Zero-Order Hold” block is under Simulink->Discrete and “To
Workspace” block is under Simulink->Sinks.

You may notice the “To Workspace” symbol above has one input and no output. What it does is to write its input
to the MATLAB workspace. The block writes its input to an array or structure (based on how you set its “Save
Format” parameter). For this assignment, set “Save Format” to “Structure with time”. The name of the array or
structure is specified by the block's “Variable name” parameter with “simout” as the default name. Array or
structure contains not only the input, but also some information about the input. To access the input data with
name “simout” , you can use the commands below:

>> Data=simout.signals.values;

>> Time = simout.time;

The above commands generate a time series that can be plotted with plot(Time, Data).

NOTE: Depending on your definitions, the output variables from the simulation may have different names or
tree structure. You can resolve that by typing “>> who” in the Command window, which will list all the variables
in the workspace. (>> whos lists the variables and their size). For a structure variable, you can then type its name
to see the first layer of the structure, e.g., >> simout. Then you can add the name of the first layer variable to
see the next one, e.g., >>simout.signals, and so on.

1. Run the above SIMULINK model with different sampling frequencies listed in the specifications. After
each run, type the commands (denoted by >>) at the command line to save the results in the workspace.
Make sure to use different variable names such as data80, time80, data400, time400, etc. Write a
MATLAB program to plot the sampled signals and the frequency magnitude character of the sampled
signals with FFT. Include your MATLAB code and figures. Compare results and discuss your observations.
(Hint: an example of how to plot FFT is in Section 4.)
2. Design a discrete low-pass Butterworth filter of order 6, sampling rate of 20,000Hz. Use “lsim” to simulate
signal reconstruction. Your data needs to be upsampled first (see note below) before passing through the
filter you designed. Specify the proper cut-off frequency of the filter. Provide the transfer function. Plot
the upsampled signals and the frequency magnitude plot of the reconstructed signals (80, 400, 1000 Hz
sampling rates as in (a)) with FFT. Include your MATLAB code and figures. Compare results and discuss
your observations.

Note: When the data needs to be upsampled, e.g., data80 contains data at 80 Hz, then the sample code below
shows how to perform this task:
data80up = upsample(data80, 20000/80) % here we upsample 80hz data to 20khz

reconstructed80 = lsim(Fil,data80up,(1:1:length(data80up))/20000); % Fil is the low-


pass filter you designed. You can also use filter command for discrete filters.

Now data80up contains the upsampled data from 80Hz to 20,000Hz, inserting 20000/80-1 = 249 zeros between
data points. You need to repeat these steps for 400Hz and 1000Hz data. Upsampling will not alleviate aliasing
problems, but will improve the signal reconstruction by reducing the undesirable properties of the low rate ZOH.

#2. In the MATLAB code provided in Section 4.4 we created a sinusoid with frequency 1 kHz. We used a high
sampling frequency of fs = 44.1 kHz that represents a fairly good approximation of the continuous time signal.
Copy the MATLAB code and run it in a script.

1. Include the plots generated.


2. Compare the analytical continuous-time Fourier transform with its FFT computation. Discuss your
observations.

#3. In the MATLAB code provided in Section 4.5 we sampled the same sinusoid (1 kHz) in Task 2 at a lower
sampling rate (fs/4) to observe the aliasing effects. Copy the MATLAB code and run it in a script. You must have all
the variables from #2 in the MATLAB workspace for this to work.

1. Include the plots generated.


2. By looking at the plots, explain whether aliasing effects have increased or decreased.

#4. In the MATLAB code provided in Section 4.6 we used upsampling to “interpolate” the values of the low rate
signal and converted it to a high rate signal and then passed the signal through a low pass filter to recover the
original signal. Copy the MATLAB code and run it in a script. You must have all the variables from #2 and #3 in the
MATLAB workspace for this to work.

1. Include the plots generated.


2. Discuss the effects of aliasing of the reconstructed signal and any effect it may have had on how it sounds
based on the results you see from running the code.

#5. In the MATLAB code provided in Section 4.7 a frequency equalizer is implemented. Copy the MATLAB code
and run it in a script.

1. Try three different sets of values for the equalization coefficients and include the frequency response
plots generated.
2. Does the frequency response correspond to what you entered as coefficients in all three cases? Explain by
using the plots from the previous part.

You might also like