project signal system 2012

22
PROJECT SIGNAL & SYSTEM 2012 The purpose and goal of this project is to further explore the course of Signals and Systems by using the matlab tool. Students will learn the basic and intermediate functions of MATLAB and apply them to the theory of Signal and System. The project objectives is to understand, demonstrate and gain experience with matlab tool. Each project is to demonstrate its problem by showing the GUI. Hints: 1. A group of two students work together and submit one report 2. Each project is to demonstrate the GUI, list of m.file 3. Provide a friendly program (help, lookfor) commands PROJECT 1 1. Recall that the Cauchy-Schwarz inequality states that for any two vectors, xand y the absolute value of the dot (scalar) product of the two vectors is less than or equal to the product of the norms of the two vectors. Moreover, equality is attained if and only one of the vectors is a multiple of the other vector. Define the three “vectors" a=[ 12345] b=[ 13579] c=[ 2478510] - Calculate the dot products of a with b , of a with c , and of b with c - Calculate the norms of each the vectors - Verify the Cauchy-Schwarz inequality for the three dot product calculated above 2. MATLAB treats the command const ./ vect to mean create a newvectors whose elements are const divided by the elements of vect. Using MATLAB and the commands we have seen, calculate (a). k=0 100 k (b). k=0 100 k 2

Upload: kurniawan-banumaxs-naga

Post on 04-Dec-2014

145 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Project Signal System 2012

PROJECT SIGNAL & SYSTEM 2012The purpose and goal of this project is to further explore the course of Signals and Systems by using the matlab tool. Students will learn the basic and intermediate functions of MATLAB and apply them to the theory of Signal and System. The project objectives is to understand, demonstrate and gain experience with matlab tool. Each project is to demonstrate its problem by showing the GUI.

Hints:

1. A group of two students work together and submit one report2. Each project is to demonstrate the GUI, list of m.file3. Provide a friendly program (help, lookfor) commands

PROJECT 1

1. Recall that the Cauchy-Schwarz inequality states that for any two vectors, x⃗and y⃗ the absolute value of the dot (scalar) product of the two vectors is less than or equal to the product of the norms of the two vectors. Moreover, equality is attained if and only one of the vectors is a multiple of the other vector.

Define the three “vectors" a⃗=[1 23 4 5] b⃗=[1 35 7 9] c⃗=[2 4 78 510]

- Calculate the dot products of a⃗ with b⃗ , of a⃗ with c⃗ , and of b⃗ with c⃗- Calculate the norms of each the vectors- Verify the Cauchy-Schwarz inequality for the three dot product calculated above

2. MATLAB treats the command const ./ vect to mean create a newvectors whose elements are const divided by the elements of vect. Using MATLAB and the commands we have seen, calculate

(a). ∑k=0

100

k

(b). ∑k=0

100

k2

(c). ∑k=0

1001k

(d). ∑k=0

1001k 2

(e). ∑k=0

100001k2

Page 2: Project Signal System 2012

3. Plot five periods of the function cos(2πt). Define a vector t with 100 elements the first of which is zero.

PROJECT 2

1. Define the symbolic variable x. Make use of this variable to definethe symbolic function sin(1/x). Then, plot the function from 0 to 2π .What do you see? Why might the plotting routine be having troubleplotting this function?

2. (Odd and even functions.) To break a function, f(x), into odd andeven parts, one can compute the two functions

f odd (x )=f (x )−f (− x)

2

f even ( x )=f ( x )+f (−x)

2

You will now perform these operations using MATLAB and examine the resulting functions.(a) Define the symbolic variable x.(b) Define the symbolic function y=ex

(c) Define the symbolic function z=e− xby making a substitution in the symbolic function you found in the previous section.

(d) Using the results of the previous two sections, calculate fodd(x) and feven(x) for the function y=ex

(e) Use ezplot to plot the functions that you found over the region [-1,1].

3. Let us evaluate sin(x) at the points π ,⋯ ,5πagain.(a). Define the symbolic vector a by giving the command a = sym('1'):sym('5'). This command should give you an array of five “ideal" numbers.(b). Define the symbol p = sym('pi'). This command gives you a variable, p, that holds an ideal

π.(c). Now have MATLAB calculate the values of sin (π ) ,⋯ , sin (5π ) using a single command.(d). What is the command's output?

PROJECT 3

1. Please calculate the convolution of the unit pulse,

p (t )={ 1 0≤ t<10ot her wise

with itself analytically.

Page 3: Project Signal System 2012

2. Using the symbolic toolbox and the tricks, have MATLAB calculate and plot the convolution of a unit pulse with itself.

3. Do for the other signal input.

PROJECT 4

1. Use the dsolvecommand to solve the differential equation y ' ' (t )=− y (t )subject to the initial conditions y (0 )=1 , y ' (0 )=0.Use theMATLAB help command (type help dsolve) if you need help withthe commands syntax. Plot the solution using the ezplotcommand.

2. Use the dsolvecommand to solve the differential equation y ' ' ( t )=−2 y '− y ( t )subject to the initialy (0 )=1 , y ' (0 )=0. conditions Plotthe solution using the ezplot command.

3. Define the matrix

A=(1 2 53 7 91 5 9)

And the vector v⃗ ,

v⃗=[159 ]Calculate A v⃗ , A2 v⃗ ,∧A−1 v⃗

4. Use MATLAB to approximate the solution of the equation y ' ' ( t )=− y (t )subject to the initial conditions y (0 )=1 , y ' (0)=0 .

5. Use MATLAB to calculate the step response of the system whose transfer function is

G (s )= 1

s2+s+1

(a). Derive the di_erential equation satisfied by the step response.(b). Use the dsolvecommand to solve the ODE.(c). Next, approximate the solution of the ODE using the techniques we have studied.(d). Compare the solutions of parts 5b and 5c.

PROJECT 5

Letsaw(t) = t

Page 4: Project Signal System 2012

for −0.5≤ t ≤0.5and continue saw(t) periodically outside of this region.

1. Calculate the Fourier coefcients associated with saw(t).2. Check Parseval's equation for saw(t) both numerically and symbolically.3. Sum the first 3 terms in the Fourier series and plot the Fourier seriesas a function of time.4. Sum the first 10 terms in the Fourier series and plot the Fourier seriesas a function of time.5. Sum the first 50 terms in the Fourier series and plot the Fourier seriesas a function of time.

PROJECT 6

1. The periodic signal x(t) is shown below. Determine the fundamental period T0.Write a MATLAB code to plot x(t), using enough points to get "smooth" curve. This is just reproducing the curve provided below.

2. Compute the Fourier series coefficients for x(t) (if you can find it in the book, that is ok). Plot the single-sided and double-sided spectra up to the 10th harmonic.

3. Plot partial sums of the Fourier series for x(t) (terms 1 through N in the infinite series). In your opinion, what is the value of N that results in a "good" reproduction of x(t).

Document your work, include plots to illustrate your work and your conclusions. Include your MATLAB code.

PROJECT 7

Consider the following two signals:

x1( t )=¿ {1 , ¿ ¿¿¿|t|≤3elsewhere

Page 5: Project Signal System 2012

x2( t )=¿ {1 , ¿ ¿¿¿|t|≤1elsewhere

a) Plot these two signals on the same figure. Use a time axis of [-5,5]. Add labels, etcb) Derive (mathematically) the Fourier Transforms X1(f) and X2(f) of these two signalsc) Write a program to compute the Fourier Transforms numerically, and compare with b)Note: you can use the Matlab command trapz for numerical integrationc) Plot the magnitude spectrum for the signals on the same figure. d) Discuss your results and explain the relationship between the spectra X1(f) and X2(f).

PROJECT 8

Write a MATLAB program to generate and plot the following periodic signal as function of time with at least 600 points. Consider plotting 4 periods and choose A, T and Δ such that A is the serial number of the first student, Δ is the serial number of the other student and T is the sum of the two serial numbers. (Example, if two students are working together with serial numbers 5 and 16, you may choose A=5, Δ=16 and T=21)

PROJECT 9

For a specific system the impulse response is h (t )=2e−t5 u(t)

Use the “conv” function in MATLAB to find the output, y (t )=x ( t )∗¿if the input, x(t), is:

a) Unit step function, u(t), (hint: your output will be the step response).

b) The periodic signal you have constructed in part 2

For every case show the input, the impulse response, and the output. (use “subplot” command)

Page 6: Project Signal System 2012

PROJECT 10

The impulse response of a linear time invariant system is given by:

a) Plot h(t) as a function of time over the interval [0,60]. Use increment of 0.02.

b) Find the theoretical Fourier transform H(ω).

c) Plot the magnitude and phase of H(ω) as a function of ω. Take the interval for ω as

[0,1000]. Take at least 500 points and use the log scale for the frequency.

d) Generate the sinusoidal with the following frequencies

- ω1=0.1 rad /sec

- ω2=100 rad /sec

e) For each sinusoid find H (ωi)change the magnitude and of input sinusoidal accordingly,

and plot the input and the output signal on the same plot. Take the time invariant over [0,200] with proper increments.

PROJECT 11

Given a pair of sequences, use discrete convolution to find the response to the input x[n] of the linear time-invariant system with impulse response h[n].

x[n]= square wave with amplitude 1

y[n]= triangle wave with amplitude 2

1. Use PLOT command to plot the input and impulse response2. Compute the convolution by hand, use MATLAB to plot the results3. Write a MATLAB function to compute the convolution of the two finite-length sequences and

plot the results.

For length N input vector x, the DFT is a length N vector X, with elements

Xk ¿=∑n=1

N

x (n )e¿¿¿

4. Use CONV command to verify the results from b).

PROJECT 12

Page 7: Project Signal System 2012

Window FunctionsThe purpose of this exercise is to explore the problem of analyzing the frequency content of a signal using the DFT. Specifically, it uses sinusoids as test signals to examine the effects of windowing and spectral sampling on frequency resolution. The project culminates in a short design problem that involves estimating the vibration frequencies of a piece of machinery from measured data.There are a number of standard window functions that can be used in DFT analysis. Two of the more common windows are the rectangular (or boxcar) window and the Hamming window. The Matlab functions boxcar and hamming can be used to generate these windows. The argument to each function is the window length (number of points).Investigate the characteristics of these two windows. First plot the window as a function of ω for 3 different lengths: 16, 64, 256. Then plot the corresponding frequency response magnitudes for these 2 windows and 3 different lengths. Be sure to use a sufficient number of points in the FFT calculation; 1024 should be adequate to show the structure of the frequency response. Plot the log of the frequency response, i.e.,10 log

10|W (e jω)|. Note: Please use subplot to consolidate these plots for easy comparison.Briefly describe your plots and discuss the relative merits of each window.

PROJECT 13

Simulating a Sampled SinusoidSampled sinusoids will be used as test signals in the remainder of this project. Write a short Matlab function that returns samples of the signal sin (2π f 0t )over the period 0 to T ωseconds taken with a sample ratef s . The inputs to the function should bef 0 (frequency of sinusoid in Hz), T ω (the length of the time interval in seconds), andf s (the sample rate in Hz). The function should return the samples along with a time vector for plotting against. You may use the template below for writing your function. Make sure that you test the function, e.g., use it to compute 1 second of a 10 Hz sinusoid sampled at 1000 Hz. Verify that your samples have a spacing of .001 seconds and that the sinusoid goes through 10 cycles in 1 second.

function [x,t]=samp_sine(f0,Tw,fs)%% SAMP_SINE Function to produce samples of a sinewave%% The user specifies the sinusoid frequency, the length of%% the time interval, and the sample frequency.%%%% Usage:%% [x,t]=samp_sine(f0,Tw,fs)%%%% Variables:%% f0 = frequency of the sinusoid (Hz)%% Tw = length of time interval (seconds)%% fs = sampling frequency (Hz)%%%% x = samples of the sinusoidal signal%% t = vector of sample times (for plotting)

PROJECT 14

Impact of DFT Length on Resolution

Consider the following test signal:

Page 8: Project Signal System 2012

x (t )=sin ( 2π (1000 ) t )+sin ( 2π (1100) t )+sin (2π (3000 ) t )(1)

Generate an 0.0024 second sample of the signal x(t) using a sample rate of 10,000 kilohertz. (Theresulting signal x[n]should contain 25 samples). Using both types of windows (rectangular andHamming) compute windowed DFT’s of three different lengths: 25, 128, 1024. In other words,multiply x[n] by w[n], where w[n] is the appropriate 25-point window (rectangular or Hamming) andthen use Matlab’s fft to compute the discrete Fourier transform. Note that the 128-point and 1024-point transforms will be zero-padded. Plot the magnitude of your results as a function of continuous time frequency. See the Hints section for help in calculating the vector of frequencies to plot against.Answer the following questions:

How do the rectangular window results compare to the Hamming window results? Are you able to see from the frequency response magnitude that the signal contains

three separatesinusoids? If so, for which DFT length can you distinguish the sinusoids? What does increasing the DFT length accomplish?

PROJECT 15

Impact ofWindow (Data) Length on Resolution

Now consider keeping the DFT length fixed while using longer intervals of samples of x(t) (Equation1). Compare results for the following data window lengths: 0.0024 seconds, 0.0049 seconds, and0.099 seconds. (These should result in 25-point, 50-point, and 100-point signal lengths, respectively.)Compute 1024-point DFT’s for each and plot the frequency response magnitudes. Again compareresults for both the rectangular and Hamming windows.Answer the following questions:

How do the rectangular window results compare to the Hamming window results? Are you able to see from the frequency response magnitude that the signal contains

three separatesinusoids? If so, for which DFT length can you distinguish the sinusoids? What does increasing the length of the data window accomplish?

PROJECT 16

Window Type: Sidelobe Levels and LeakageIn this part you will consider how a high-amplitude sinusoid might mask a low-amplitude sinusoiddue to leakage effects (caused by the data window). Consider 2 sinusoidal signals, x1and x2 withdifferent amplitudes:

x1 (t )=sin ¿x1 ( t )=0.031 sin ¿

Sample these signals at a rate of 1,000 Hz over an interval of 0.127 seconds, to obtain the 128-pointSignalsx1and x2. Letx [n ]=x1 [n ]+x2[n].Use a DFT length of 1024-points to compute the windowed transforms of the total signal x[n] andthe signalx1[n] by itself. Compare the results for two different windows: 128-point rectangular vs.128-point Hamming. Use plots of 10 log10|X| and 10 log10|X1|to make your comparisons.Answer the following questions:

Describe what you observe in these plots. How do the sidelobe levels of the windows affect the results?

Page 9: Project Signal System 2012

Which window(s) allow you to detect the presence of both sinusoids? Why?

Hints on plotting the frequency responses

Plotting the frequency response requires obtaining a vector of frequencies to plot against. The discrete-time frequency vector may be defined as:

w=(2*pi/N)*[ 0:(N-1) ]’; % Set up vector of omegas: 0 to 2pi

In this case the samples range from 0 to 2π . For plotting it is sometimes useful to have the samples go from −π ¿+π. The fftshift command can be used to rearrange the samples of the spectrum for plotting this way, e.g., Xnew=fftshift(X). You will need a new vector of frequency samples to plot Xnew against.

The following Matlab commands compute the new frequency vector and store back in the variable w:mid=ceil(N/2)+1;w(mid:N)=w(mid:N)-2*pi; % move [pi,2pi) to [-pi,0)

Note: For this project, you need to convert your discrete-time frequency to continuous-time frequency (by the usual transformation) and then divide out2πto get a frequency vector in Hz.

PROJECT 17

Consider the system block diagram shown below:

(a) Use the series function to find the numerator and denominator polynomial coefficient vectors for the cascade connection of G1(s) and G2(s). Use the printsysfunction to find the overall transfer function

G (s )=Y (s)R(s)

Hint: in the Matlab help, terms like SYS, SYS1, etc., refer to the specificationof a system by a pair of vectors that give the coefficients for the numerator anddenominator polynomials of the transfer function. For example,>> numG1= [1 1];>> denG1=[1 2];>> numG2=[1];>> denG2=[500 0 0];>> [num,den]=series(numG2,denG2,numG1,denG1);

Page 10: Project Signal System 2012

>> printsys(num,den);

(b) Use impulse to plot the system impulse response g(t). Note: impulse assumesthat the system is causal (ROC of the transfer function is a right half-plane).(c) Use step to plot the system step response.(d) Plot the signal

r ( t )=e−t cos (5 πt )u( t)

for t ϵ [0, 5] using a time resolution of 0.002 sec. Use lsim with a left-handargument to plot the system response for t ϵ [0, 5] when r(t) is the system input.Use a time resolution of 0.002 sec for your plot.(e) Use pzmapwith left-hand arguments to observe the poles and zeros of G(s). Isthe system stable? (Justify your answer).(f) Usepzmapwithout left-hand arguments to generate a pole-zero plot for G(s).

PROJECT 18

Consider the feedback system depicted in the block diagram below:

Note that the gain of the feedback path is unity (1).(a) Use feedback to find the numerator and denominator polynomial coefficient vectors of the

closed-loop transfer function

G (s )=Y (s)R(s)

For feedback, you will need the numerator and denominator polynomial coefficient vectors for the series connection of G1(s) and G2(s) that you obtained in the above (problem (1)). The transfer function of the feedback path in the system block diagram above is equal to one, so you can describe it with the numerator polynomial coefficient vector [1] and the denominator polynomial coefficient vector [1].

(b) Use printsysto find G(s).(c) Use impulseto plot the system impulse response g(t). Give a brief qualitativedescription of

the main effect of adding feedback to this system as compared tothe system in problem (1).(d) Use pzmapwith left-hand arguments to observe the poles and zeros of G(s). Isthe system

stable? (Justify your answer).(e) Use pzmapwithout left-hand arguments to generate a pole-zero plot for G(s).(f) Plot the signal

Page 11: Project Signal System 2012

r ( t )=e−t

10000 cos ( π500

t )u( t)for t ϵ [0, 20000] using a time resolution of 10 sec. Use lsim to plot the systemresponse when r(t) is the system input for t ϵ [0, 20000] using a time resolution of 10 sec.

PROJECT 19

Consider the feedback system depicted in the block diagram below:

(a) Use feedback to find the numerator and denominator polynomial coefficient vectors of the closed-loop transfer function

G (s )=Y (s)R(s)

(b) Use printsys to find G(s).(c) Use impulse to plot the system impulse response g(t).(d) Use pzmap with left-hand arguments to observe the poles and zeros of G(s). Is itcausal?

Is the system stable? (Justify your answers).(e) Use pzmap without left-hand arguments to generate a pole-zero plot for G(s).

PROJECT 20

Page 12: Project Signal System 2012

H is a causal discrete-time LTI system with input x[n] and output y[n] related by the linear constant coefficients difference equation

y[n] = 0.6y[n − 1] + x[n]

(a) Find the transfer function H(z) analytically (using paper and pencil). Use zplane to generate a pole-zero plot for H(z). Is the system stable? (Justify your answer).

Note:You should get the vector [1] for the numerator polynomial coefficientvector of H(z). On some versions of Matlab, this will create an incorrect polezeroplot; the plot may show an incorrect zero at z = 1. If this happens, you canfix it by using [1 0] for the numerator coefficient vector. The vectors [1] and [1 0]actually specify the same numerator for H(z), since 1 = 1 + 0z−1.

(b) Use freqzto plot the magnitude |H(ej!)| and phase ]H(ej!) of the system frequency response H (e jω )using N = 1024 points.

(c) Use impzto plot the system impulse response h[n].

PROJECT 21

What kind of system is described by the transfer function

G (s )= 1τs+1

τ>0

(a). Define the transfer function ogject, G.

(b). Find the impulse respons of the system

(c). Explain the frequency of oscillation that you see.

(d). Find the step response of the system.

(e) Explain why the step response of the system starts from zero and ends at zero.

PROJECT 2 2

Analyze the system whose transfer function is

G (s )= s

s2+s+(2π )2

(a). Define the transfer function ogject, G.

(b). Find the impulse respons of the system

(c). Explain the frequency of oscillation that you see.

(d). Find the step response of the system.

(e) Explain why the step response of the system starts from zero and ends at zero.

Page 13: Project Signal System 2012

PROJECT 2 3

Analyze the system whose transfer function is

G (s )= −s+1

2 s2+s+3

(a). Use the ltiviewcommand to open the ltiviewer|the linear time-invariant system viewer. Use the help command to discover how this command is used.

(b). Have the ltiviewer display the step and impulse responses of the system.(c). Explain why the step response of the system is initially negative.

1. Consider the system of Figure belows. Let H(s) = 1. Have MATLABcalculate the step response of the system described by the figure when:

(a). G (s )=0.125 /(s2+s)(b). G (s )=0.25 /(s2+s)(c). G (s )=0.50 /(s2+s)(d). G (s )=1/ (s2+s)

What effect does the increased gain have on the system's performance? (Please address both the system's rise time and the amount of overshoot in the system's output.)

PROJECT 2 4

1. Design a fourth order high-pass Butterworth filter whose cutoff frequency is 1,000 rad/s.(a) What is the transfer function of the filter?(b) Plot the magnitude response of the filter.(c) What is the high-frequency rolloff?

Page 14: Project Signal System 2012

2. Compare the performance of a fourth-order low-pass Chebyshev filter with a cutoff frequency of 1 kHz with the performance of Butterworthfilter of the same order.(a) Use the MATLAB helpcommand to learn how to use the cheby2command.(b) Use the commands butterand cheby2 to design the two filters.(c) Plot the magnitude plots of the two filters.(d) Which of the filters has a narrower transition region?(e) Which of the filters has a “prettier" magnitude response?

PROJECT 2 5

1. Show that the expression

0.5t+0.5 a|t+0.5|

−0.5t−0.5

|t−0.5|

is, in fact, equal to ∏a

(t). You may want to examine the value of the expression when

t<0.5a , −0.5a≤ t ≤0.5a, and when t>0.5a

2. Xmake use of symbolic toolbox to calculate the Fourier transform of

g ( t )=¿

3. Make use of the symbolic toolbox to calculate the Fourier transform of

g ( t )=e−|t|

It may be necessary to calculate the Fourier transform of g(t) by calculating the integral from −∞to 0 and from 0 to ∞separately. Then, of course, one must add the two results to get the final result.

4. Calculate and plot the Fourier transform of ∏1

( t ) cos (2 π100 t ) .

5. Make use of the symbolic toolbox to calculate the Z-transform of thesequences:

(a) ak={ k2 k ≥00ot herwise

(b) ak=b−|k|

PROJECT 2 6

Second Order ResponseConsider a transfer function of the following form corresponding to a right-sided response.

Page 15: Project Signal System 2012

H ( z )= z

z2+2 ℜ [ p ] z+|p|2

The pole pis complex. Let p=r e jφ

For this question, r=0.9and φ=π /2.(a) Use the Matlab function zplane to plot the poles and zeros of H(z) .(b) Use freqz to calculate the complex frequency response. Plot the magnitude and phase of

thefrequency response corresponding to H(z) . Categorize this response in terms of is it lowpass,highpass, bandpass, or bandstop.

(c) The group delay of a response is given by

τ g (ω)=−dθ(ω)dω

A “good” group delay is one which is constant with frequency. What does this constancy imply for the phase? Why would filter designers prefer to deal with group delay rather than phase response? Use the Matlab function grpdelay to get the group delay associated with the filter given above. Plot the group delay. What are the units of group delay? Label the axis appropriately.

(d) Plot the impulse response of the filter (first 20 or so samples).

PROJECT 2 7

DTFT for FIR signalsWe have been using the routine freqz to compute frequency responses. In this problem you will write your own DTFT routine for finite length sequences. The DTFT will be of the form

function H = DTFTFIR (h, n, w)nw = length(w);nh = length(h);for (k = 1:nw)H(k) = …endreturn

The input to this routine is a set of response values (h) with corresponding values of time indices (n), and a vector of frequencies for which the response is to be evaluated. Test your routine against freqz using the following two sets of responses (use frequencies from 0 to π in, say, 100 steps). Plot the magnitude response and the phase response for each case.(a) h = [4 3 2 1 1 2 3 4];

n = -2:5;Explain the shape of the phase response curve – specifically, why are there jumps in the

function? Hint: where do the jumps occur with respect to the magnitude curve?(b) n = 0:20;

h = n .* (0.9).^n;

PROJECT 2 8

Page 16: Project Signal System 2012

DTFT for IIR signalsWe have been using the routine freqz to compute frequency responses. In this problem you will write your own DTFT routine for infinite length sequences specified by a numerator polynomial and a denominator polynomial (polynomials in 1 z). The DTFT will be of the formfunction H = DTFTIIR (b, a, w)nw = length(w);nb = length(b);na = length(a);for (k = 1:nw)H(k) = …endreturn

To do this first consider the rational polynomial

H ( z )= B(z )A (z)

=b0+b1 z

−1+…+bM z−M

a0+a1 z−1+…+aN z

−N

It is then clear that the frequency response corresponding to H(z) for a series of frequencies is the point-bypoint division of the frequency response of B(z) divided by the frequency response of A(z) .Write your DTFT routine and test it on the following responses. Plot the magnitude and phase for each, comparing the results with those from freqz.

(a)h [n ]=(0.5)nu (n)

(b)H ( z )= 1+z−1+z−2+z−3

1−0.18 z−1+0.81 z−2

PROJECT 29

Given the following system for sampling and reconstruction:

Page 17: Project Signal System 2012

Where:x(t) – is the input signalp(t) – is the sampling signalxp(t) – is the sampled signalh(t) – is the impulse response of the Low Pass FilterH(ω) – is the Transfer Function of the Low Pass Filtery(t) – is the output signal.

Using the matlab:1. Plot the input signal x(t) according to the conditions shown in Figure 1.2. Plot the sampling signal p(t) according to the conditions shown in Figure 2.3. Plot the sampled signal xp(t).4. Plot the spectra of the input signal x(t), sampling signal p(t) and sampled signalxp(t) [i.e.

X(ω), P(ω) and X(ω)].5. Design the Low Pass Filter which allows reconstructing the original input signal(with

permissible error). Using the matlab plot the frequency response of thedesigned filter.6. Plot the reconstructed signal spectrum Y(ω).

The parameters of the x(t) and p(t) are defined as follows:τ, τp, T and A choose as variable.

PROJECT 30

In real applications you will always have a small amount of additive noise. This usually approximated with a Gaussian random process with zero mean and zero covariance between different time samples. To add noise in MATLAB you could write:

> Var=1; %Variance of the noise> signal_noise = signal + Var*randn(size(signal));

Try some different values of the variance and listen to the signal. Also look what happens with the signal, by plotting the first two periods of the signal. Plot the signal both without noise and with different variance of noise in the same figure. This could be done by writing:

> figure; %Opens a new figure window> a= %How many samples are two periods of the signal?> plot(noisysignal(1:a),’b’);> hold on; %We can now plot more than one signal in the figure

Page 18: Project Signal System 2012

> plot(signal(1:a),’r’); %Next plot

Type help plot and look how you can control the colour and appearance of the plotted signal. The signal seems to be continuous, but that’s only because the plot command draw lines between each sample. Add some circles by changing the plotting options. Also, what scale is on the x-axis? How can you change this so you have the correct scaling? (Remember, the signal is one second long).