You are on page 1of 4


IT (Hons) III

Digital Signal Processing and Filters

Practical Assignment
Dr. Ing. Victor Buttigieg Department of Communications and Computer Engineering, University of Malta

The Sampling Theorem

Objectives: To observe the effects of over-sampling, under-sampling and sample duration. Procedure: 1. Use Simulink to build the system shown in Figure 1. The sine wave generator is the signal under investigation. The pulse generator is used to sample the signal. The output of the pulse generator periodically varies between 0 and 1. When the output of the pulse generator is 1, a sample value is outputted from the product block and displayed on the Scope. 2. Set the frequency of the sine wave block to 1kHz, wit h amplitude 1, 0 phase and 0 sample time. A zero sample time indicates to Simulink that the output is continuous in time. 3. Set the amplitude of the pulse generator to 1; period 10 samples (choose a pulse type Sample-Based); pulse width 1 sample; phase dela y 0; Sample time 10 s. Therefore, the systems sampling frequency is 1/10 s = 100kHz. However, the sine wave is being sampled (by means of the pulse generator) at 100kHz/10 = 10kHz (every 10 system samples). 4. Set the parameters for both Averaging Power Spectral Density blocks to: Length of buffer 200; Number of points for fft 512; Plot after how many points 64; Sample time 10s. 5. Set the Save Format parameter of the To Workspace block to array and the variable

Original Signal Averaging Power Spectral Density

Sampled Version Averaging Power Spectral Density

Sine Wave



y To Workspace Pulse Generator

Figure 1

name to y. 6. Set the simulation stop time to 10ms (10 periods of the sine wave) and simulate the model. Observe the output on the Scope and the two Averaging Power Spectral Density blocks. 7. In order to determine better the frequency components at the output, this is saved in the Matlab variable y. Go to the Matlab window and type length(y) This gives the number of samples in y. Check to verify that the returned number makes sense. 8. Next, type the following commands in Matlab: stem(y,'b.-') title('Time plot') figure freq=fft(y); plot(abs(freq)) title('Frequency Spectrum') Two figures should be plotted, one a time plot (the sampled sine wave stored in y) and the other the magnitude frequency spectrum for y. The x-axis in the frequency spectrum curve should be interpreted as follows. If N is the number of samples in y, then N sampling frequency = 100kHz. Hence, a spectral line at a value of k on this plot represents the frequency (by simple proportion) k /N100kHz. Record the values of k for the spectral lines obtained in the Frequency Spectrum plot and calculate the corresponding values in Hz. Verify that these values agree with the sampling theorem. 9. Change the frequency of the sine wave in the Simulink model to 8kHz and repeat steps 6-8. Comment on the results obtained. 10. Change the frequency of the sine wave in the Simulink model back to 1kHz. In the Pulse Generator block set the pulse width to 4 samples. Repeat steps 6-8. Comment on the results obtained. 11. Increase the pulse width of the Pulse Generator to 6 samples. Can you note any difference in the frequency spectrum? 12. Using Simulink, build the model shown in Figure 2. 13. Set the frequency of the discrete time sine wave to 1kHz and the sampling frequency to 10kHz. 14. Set the frequency of the continuous time sine wave to 1kHz. Do not forget to set the sample time to zero.

b(s) a(s) Transfer Fcn Filtered Output Scope


Sine Wave

Averaging Power Spectral Density y To Workspace

Figure 2 15. The continuous time filter shown in the model of Figure 2 is a Chebyshev low pass filter with the following parameters: Pass band cut-off frequency: Stop-band frequency: Pass band ripple: Attenuation at 5.5kHz: 5kHz 5.5kHz 1.5dB 80dB

The numerator polynomial b(s ) and the denominator polynomial a(s ) can be obtained by the following instructions: % Pass band cut-off frequency Wp = 2*pi*5e3; % Stop band frequency Ws = 2*pi*5.5e3; %Pass band ripple in dB Rp=1.5; %Attenuation at the stop band frequency (in dB) Rs=80; %Determine the order of the Chebyshev filter [n,Wn]=cheb1ord(Wp,Ws,Rp,Rs,'s'); %Determine the transfer function of the Chebyshev filter in a and b. [b,a]=cheby1(n,Rp,Wn,'s'); %Plot the response of the filter freqs(b,a);

Set the numerator and the denominator parameters for the Transfer Fcn block to b and a respectively. 16. Set the simulation stop time to 10ms and the relative tolerance to 10-6 . Both these parameters are set from the Simulation Parameters Dialog box and simulate the model. 17. Comment on the results obtained. 18. Change the frequencies of both sine wave blocks to 8kHz and repeat steps 16 and 17.