You are on page 1of 17

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, and 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" - Calculate the dot products of with , of with , and of with - 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). (b). (c). (d). (e).

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 ( ) ( ) ( ) ( ) ( ) ( )

You will now perform these operations using MATLAB and examine the resulting functions. (a) Define the symbolic variable x. (b) Define the symbolic function (c) Define the symbolic function by 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 (e) Use ezplot to plot the functions that you found over the region [-1,1]. 3. Let us evaluate sin(x) at the points 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 ( ) ( ) using a single command. (d). What is the command's output?

PROJECT 3
1. Please calculate the convolution of the unit pulse, ( ) with itself analytically. 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
( )subject to the initial 1. Use the dsolvecommand to solve the differential equation ( ) ( ) conditions ( ) Use theMATLAB help command (type help dsolve) if you need help withthe commands syntax. Plot the solution using the ezplotcommand. ( )subject to the 2. Use the dsolvecommand to solve the differential equation ( ) ( ) initial ( ) conditions Plotthe solution using the ezplot command. 3. Define the matrix ( And the vector , Calculate ( ) ( )subject to the initial [ ] )

4. Use MATLAB to approximate the solution of the equation conditions ( ) ( ) .

5. Use MATLAB to calculate the step response of the system whose transfer function is ( ) (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
Let saw(t) = t for 1. 2. 3. 4. 5. and continue saw(t) periodically outside of this region. Calculate the Fourier coefcients associated with saw(t). Check Parseval's equation for saw(t) both numerically and symbolically. Sum the first 3 terms in the Fourier series and plot the Fourier seriesas a function of time. Sum the first 10 terms in the Fourier series and plot the Fourier seriesas a function of time. 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:

1, | t | 3 x1 (t ) 0, elsewhere

1, | t | 1 x 2 (t ) 0, elsewhere
a) Plot these two signals on the same figure. Use a time axis of [-5,5]. Add labels, etc b) Derive (mathematically) the Fourier Transforms X1(f) and X2(f) of these two signals c) Write a program to compute the Fourier Transforms numerically, and compare with b) Note: you can use the Matlab command trapz for numerical integration c) 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 ( ) ( ) ( ) ( ( )if the input, x(t), is:

Use the conv function in MATLAB to find the output, ( )

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)

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

e) For each sinusoid find ( )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 response 2. Compute the convolution by hand, use MATLAB to plot the results 3. 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 ) ( )
(
( )( )

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

PROJECT 12
Window Functions The 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.,

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 Sinusoid Sampled sinusoids will be used as test signals in the remainder of this project. Write a short Matlab function that returns samples of the signal ( )over the period 0 to seconds taken with a sample rate . The inputs to the function should be (frequency of sinusoid in Hz), (the length of the time interval in seconds), and (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: ( ) ( ( ) ) ( ( ) ) ( ( ) ) ( )

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 DFTs 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 Matlabs fft to compute the discrete Fourier transform. Note that the 128point 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 DFTs 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 Leakage In 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, withdifferent amplitudes: ( ) ( ( ) ) ( ) ( ) ( ( ) ) ( )

and

Sample these signals at a rate of 1,000 Hz over an interval of 0.127 seconds, to obtain the 128pointSignals and . Let . Use a DFT length of 1024-points to compute the windowed transforms of the total signal x[n] andthe signal by itself. Compare the results for two different windows: 128-point rectangular vs. | | and | |to make your comparisons. 128-point Hamming. Use plots of Answer the following questions: Describe what you observe in these plots. How do the sidelobe levels of the windows affect the results? 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 printsys function to find the overall transfer function ( ) ( ) ( )

Hint: in the Matlab help, terms like SYS, SYS1, etc., refer to the specification of a system by a pair of vectors that give the coefficients for the numerator and denominator 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); >> printsys(num,den); (b) Use impulse to plot the system impulse response g(t). Note: impulse assumes that 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 ( ) ( ) ( )

for t [0, 5] using a time resolution of 0.002 sec. Use lsim with a left-hand argument 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). Is the 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 ( ) ( ) ( )

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 ( ) ( ) ( )

for t [0, 20000] using a time resolution of 10 sec. Use lsim to plot the system response 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 ( ) ( ) ( )

(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
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 + 0z1. (b) Use freqzto plot the magnitude |H(ej!)| and phase ]H(ej!) of the system frequency response ( )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 ( ) (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 22
Analyze the system whose transfer function is ( ) (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 23
Analyze the system whose transfer function is ( ) (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). (b). (c). (d).

( ( ( (

) ) ) )

( ( ( ( ) ) )

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 24
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? 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 25
1. Show that the expression

is, in fact, equal to ( ). You may want to examine the value of the expression when , , and when 2. Xmake use of symbolic toolbox to calculate the Fourier transform of

( )

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


| |

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 ( ) 5. Make use of the symbolic toolbox to calculate the Z-transform of thesequences: (a) (b) {
| |

PROJECT 26
Second Order Response
Consider a transfer function of the following form corresponding to a right-sided response. ( ) | |

The pole p is complex. Let For this question, r=0.9 and . (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 ( ) ( ) 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 27
DTFT for FIR signals
We 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) = end return 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 28
DTFT for IIR signals
We 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 form function H = DTFTIIR (b, a, w) nw = length(w); nb = length(b); na = length(a); for (k = 1:nw) H(k) = end return To do this first consider the rational polynomial ( ) ( ) ( ) 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) (b) ( )

( )

PROJECT 29

Given the following system for sampling and reconstruction:

Where: x(t) is the input signal p(t) is the sampling signal xp(t) is the sampled signal h(t) is the impulse response of the Low Pass Filter H() is the Transfer Function of the Low Pass Filter y(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 > 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 thats 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).

You might also like