Matlab

paredan
Homework7.pdf

ECE334: Discrete Signals and Systems Dr. Ratliff – Fall 2017

Homework 7, Due October 31st, 2017

Note: To receive full credit your work must be organized and neat. Generate all plots in MATLAB and submit a hard copy of your work in class by the due date.

Problem 1. A continuous-time signal is given by y(t) = 7.2 cos(1200πt − π/2).

a. What is the frequency in hertz of y(t)?

b. What is the period of y(t)?

c. If y(t) is to be represented by its sample values, what is the minimum frequency at which it should be sampled?

d. What is the sampling period for the frequency found in part (d.)?

e. If y(t) is sampled with a period of T = 0.001sec, find the expression for the resulting sequence y[n].

f. What is the digital frequency, ω, of y[n] for the value of T given in part (f.)?

Problem 2. The signal y(t) = cos(2πt), −∞ < t < ∞, is to be sampled using the sampling function, s(t), with a sampling frequency fs. An ideal low-pass filter

H(ω) =

{ f−1s , |ω| ≤ B 0, |ω| > B

is used to reconstruct y(t) from its samples, y[n]. This sampling and reconstruction process is illustrated in the figure below:

This figure will be useful for helping you answer the following questions:

a. What is the minimum fs (Nyquist rate) that will insure a perfect reconstruction? Support your answer with figure above.

b. For a given sampling frequency fs beyond the Nyquist rate, what are the minimum and maximum values of the filter bandwidth B for which perfect reconstruction is guaranteed? Explain what could go wrong if these conditions are not met by the filter. Support your answer with the figure above.

1

c. Study the attached MATLAB code (this .m file can be downloaded from the Homework folder on the course website). Notice that the filter bandwidth has been parameterized such that B = 2πp. For a fixed sampling time T satisfying the Nyquist condition, what are the minimum and maximum values of the bandwidth parameter p for which perfect reconstruction is possible?

d. Set T = 0.4 and run the program for values of p = {0.5, 1.2, 1.5, 4.0}. Plot the reconstructed signal in each case and discuss:

• The original versus the reconstructed signal in regards to aliasing and amplitude. • Sketch a Fourier domain plot similar to the bottom-right plot above that shows the indicated filter overlaid

upon the signal and discuss the suitability of the filter bandwidth and the frequency components of the reconstructed signal.

e. Now fix p = 1.2 and increase T until the reconstructed signal is reasonably distorted. What is the corresponding T? Explain.

f. If we are forced to use a filter with B = 6π radians/sec, what is the requirement on T so that alias-free reconstruction is achieved? Support your answer using the MATLAB program.

MATLAB Source Code for Problem 2

% ECE334 % MATLAB program f o r sampling and r e c o n s t r u c t i o n of s i n u s o i d a l s i g n a l s % Bradley M. R a t l i f f , Ph .D. c l e a r a l l ; c l o s e a l l ; c l c ;

% Time range parameter : −r < t < r R = 2; % Bandwidth parameter : B = 2∗ pi ∗p p = 4 . 0 ; % Bandwidth of the f i l t e r B = 2∗ pi ∗p ; % Sampling period T = 0 . 4 ; % Parameter determining the spacing of time in the reconstructed s i g n a l . n = 50;

% Time vector f o r the reconstructed s i g n a l t = [−R: 0 . 0 1 / n :R ] ; Lt = length ( t ) ; % Sampling time vector f o r d i s c r e t e s i g n a l nT = [−R:T:R ] ; LnT = length (nT ) ;

y = cos (2∗ pi ∗ t ) ; % Continuous−time s i g n a l to be sampled ys = cos (2∗ pi ∗nT ) ; % Sampled d i s c r e t e −time s i g n a l

% Generate f i l t e r array h [ t−nT] , i . e . , LnT s h i f t e d s i n c f u n c t i o n s . We do i t % t h i s way so that we can r ec o n s t r u ct the o r i g i n a l s i g n a l using the time % vector t . h = zeros (LnT, Lt ) ; f o r k=1:LnT

N = k − ((LnT − 1)/2) − 1; h(k , : ) = ( (B∗T)/ pi ) ∗ s i n (B∗( t−N∗T)) ./ (B∗( t−N∗T) ) ;

end

% The reconstructed signal , created using the r e c o n s t r u c t i o n formula . YS = repmat ( ys ’ , 1 , s i z e (h , 2 ) ) ; yr = sum(YS. ∗ h , 1 ) ;

Mxyr = max(max( abs ( yr ) ) , 1 ) ; %Find max value f o r s e t t i n g plot axis plot ( t , y , ’ : ’ , ’ LineWidth ’ , 2 ) ; hold on ; stem (nT, ys , ’ k ’ , ’ f i l l e d ’ ) ; plot ( t , yr , ’ LineWidth ’ , 1 ) ; axis ([ −R R −1.5∗Mxyr 1.5∗Mxyr ] ) ; x l a b e l ( ’ time , $$t$$ ’ , ’ i n t e r p r e t e r ’ , ’ latex ’ ) ; t i t l e ( ’ $$T=0.4 , p=0.5$$ ’ , ’ i n t e r p r e t e r ’ , ’ latex ’ ) ; l e g = legend ( ’ $$y ( t ) $$ ’ , ’ $$y s [nT] $$ ’ , ’ $$y r ( t ) $$ ’ ) ; s e t ( leg , ’ I n t e r p r e t e r ’ , ’ latex ’ ) ;

2