MatLap - signals and systems

profilefaisal1992
matlab-hw.pdf

EEE 203: Extra Credit MATLAB Assignment

Due on the day of your final exam

1. Convolution of two boxes one of size 5 and one of size 8. Give plots of the boxes and the convolution reslt. (Use the code in the MATLAB handout under Course Documents in Blackboard.)

2. Convolution of a box of size 5 with the exponential function exp(−x/2) where x = [0 : 20]. Give plots of the two functions and the convolution result.

3. Discrete-Time Fourier Transform of a box centered at 0.

Centered Box Signal

• Generate a box of length 5, x[n] = u[n+ 2]− u[n− 3]: time length = 128; box length = 5; time = (- time length/2 + 1):1:(time length/2); box signal = (time >= -(box length-1)/2 ) & (time <= (box length-1)/2);

• Plot the generated box signal: figure(1); stem(time, box signal); xlim([-box length, box length]); title(’Centered Box Signal’); ylim([0,2]);

• Set the length of FFT: FT length = 128;

• Take the FFT of the box signal: box FT = fftshift(fft(box signal, FT length));

• The x-axis for the frequency domain signal is the normalised frequency: f = ( -(FT length/2)+1:FT length/2) / FT length;

• Plot the absolute value of the FT as a function of f: figure(2); plot(f, abs( box FT ));

• Label the axis: xlabel(’Normalised Frequency’); ylabel(’Magnitude’); title(’Fourier Transform of a box signal’);

Deliverables: Commented code, plots showing the input signal and its FT. What does fftshift do?

4. Discrete-Time Fourier Transform of a shifted box signal, x[n] = u[n] − u[n − 5]. Show both the magnitude and the phase spectrum of the new box signal. You may use angle() to get the phase spectrum.

1