Sei sulla pagina 1di 3

SHARIF UNIVERSITY OF TECHNOLOGY ELECTRICAL ENGINEERING DEPARTMENT

DIGITAL SIGNAL PROCESSING FALL 2010 DR. TEBIANI

INTRODUCTION TO MATLAB PUBLISHED: 8 NOV. 2010 DEADLINE: 21 NOV. 2010

The goal of this homework is that students become familiar with MATLAB, using simple signal processing commands. The necessary commands are given during practice, for help you should consult the provided tutorials and help including MATLAB.

MATLAB homework
interval with following definition:

I. FILTERING IN 1-D 1. Construct vector in

2. Plot

and its DFT magnitude in a figure next to each other, using FFT command.

Note: in fact you should use stem command for plotting discrete signals, but sometimes when there are too many samples, the signal is not recognizable from stem. So feel free to use plot and stem interchangeably whenever needed and dont worry about your grade!

3. This time construct

in

interval and redo 2nd step. Compare two recent figures.

Note: when you are working with discrete signals in MATLAB all frequency properties are denoted per unit, For example has period and frequency. So the maximum possible frequency in discrete signals with finite length is and the minimum possible frequency is (why?).

Now can you explain recent difference? 4. In this part we would like to remove second term from 5. Write a function with following signature:

by means of filtering.

function output = FFT_LP(input, cutoffFrequency, passbandGain)

the function should filter input signal with given properties, using FFT and IFFT.(cutoff frequency should be in unit).
Note: IFFT is the inverse of FFT, so you can apply your changes on FFT and then turn it back to time domain. Although IFFT should return real signal when FFT is symmetric, because of rand-off error the result has negligible imaginary part that you can get rid of it by means of property 'symmetric' in IFFT(see help) or real command.

6. Use your function and filter with proper cutoff frequency to remove second term. Plot filtered signal like 2nd step. 7. Ideal low pass filters are not realizable, so we should know how to design a non-ideal filter in MATLAB. MATLAB has fdatool for this purpose that will be discussed in MATLAB classes; but here we become familiar with fir2 command.
B = fir2(N,F,A)

Where vectors F and A specify the frequency and magnitude breakpoints for the filter such that plot(F,A)would show a plot of the desired frequency response and function returns a vector (B) with length that is impulse response of the desired filter, for example fir2(9,[0 0.5 0.5 1],[1 1 0 0]) returns a low pass filter with cutoff frequency on and length . 8. Now design a proper filter with fir2 command and convolve it with , then plot filtered y and its DFT magnitude and compare with results in 6th step. Also plot s DFT and DFT of designed filter on each other in a figure (see hold on command).
Note: convolution command in MATLAB is conv. You can specify outputs length to be the same as input, for more info read its help.

II. FILTERING IN 2-D 1. Assign integers belong to

interval to :
n = 0:100;

2. Construct

and

matrixes as follow:
[n_x n_y] = meshgrid(n);

3. Obtain matrix with definition below by means of

and

matrixes.

4. Now run command below and explain what commands meshgrid and surf do.
surf(n_x,n_y,z) Note: Henceforth when it is stated that plot a matrix, it means use surf command not plot.

5. Plot z and its DFT magnitude in a figure next to each other using FFT2 command.. 6. Redo 5th step for following :

7. Compare two recent figures and describe FFT in 2-D.

8. Write a function with following signature:


function output = FFT2_LP(input, cutoffFrequency, passbandGain)

the function should filter input matrix with given properties, using FFT2 and IFFT2.(cutoff frequency should be in unit). 9. Use your function to filter in order to remove added term toward first definition and plot results. Note: A printed version of your report including m-files, plots and description of your algorithm and other calculations should be handed in by the deadline. In addition, upload your zip-file including report and m-files in the SUT courseware and if it doesnt work (!!), email your zip-file to a.ayremlou@gmail.com. Your email subject should be MHW1_IDxxxxxxxx, where xxxxxxxx is your 8-digit student ID. Name your main programs (not the functions) MHW1_N.m (N=1, 2, 3). By running these m-files, all the curves should be plotted. Note that no one will debug your code. Good commenting and formal reports (using IEEE full paper template or latex) will be rewarded by bonus points!!

Copyright 2010 Ali Ayremlou


a.ayremlou@gmail.com

Potrebbero piacerti anche