EEE 413 DIGITAL SIGNAL PROCESSING LAB ASSIGNMENT 2 Objective: You will learn about creating continuous and discrete signals, working with difference equations, and convolution in Matlab using the code provided to you below. 1. Matlab Code % EEE 413 Digital Signal Processing Laboratory % MATLAB simulations I : Disrete-time Signals and Systems clear all ;clc %Example 1: % Discrete-time LTI system with difference equation (IIR system): % y(n) = y(n – 1) + 2*y(n – 2) + x(n – 2) % and input: x(n) = 4*cos(pi*n/8), and initial conditions: y(0) = 1 and y(1) = 1 y=[1 1]; x(1)=4; x(2)=4*cos(pi/8); for n = 3:11 n1= n-1; x(n) = 4*cos(pi*n1/8); y(n) = y(n-1) + 2*y(n-2) + x(n-2); end % stem-plot output vector y(n) figure(1) stem(y); xlabel('n'); ylabel('y(n)'); title('system output y(n)'); %Example 2: %Find the system output y(n), 0 <= n <= 10, of a LTI system when the %input x(n) = (0.8^n)*[u(n) – u(n-5)] and the impulse response %h(n) = (0.5^n)*[u(n) – u(n – 10)]. n1 = 0:4; x = 0.8.^n1; n2 = 0:9; h = 0.5.^n2; y = conv(x,h); k1 = size(n1,2) + size(n2,2)-1; %length of convolution output y k = 0:k1-1; figure(2) subplot(3,1,1), stem(n1,x); xlabel('n');title('x(n)'); subplot(3,1,2), stem(n2,h); xlabel('n');title('h(n)'); subplot(3,1,3), stem(k,y); xlabel('n');title('y(n)'); 2. Assignment (Due on 21-10-2015) a. Define two simple, pure sinusoidal(sine or cosine wave) signals both in continuous and discrete time and plot them. b. Define and plot two sinusoidal signals with additive noise. c. Find the output y[n] for the given system. System function : h[n]= 1.5^n*(u[n] – u[n-7]) Input Function : x[n] = 0.5^n*(u[n]-u[n-3]) Display all of the results and graphs! Hint: You may use following functions for your assignment. %Continuous Time Unit Step Function Code function y = us(x) y = (sign(x) + 1)/2; end, %Discrete time unit sequence function y = usD(n) y =double(n >= 0); % Set output to one for non% negative arguments I = find(round(n) ~= n); % Index non-integer values of n y(I) = NaN ; % Set those return values to NaN end