# Calculate several samples of t

Calculate several samples of the unit impulse and impulseresponses of y(n) = -0.75 y(n–1) + x(n) – 0.3 x(n–1) – 0.4x(n-2).

** Re-write** the equation in standard formand then

**the name of eachcoefficient (a**

*indicate*_{1}, etc.). Use the filter() function inMATLAB to check your results to 1 and 2.

Answer:

**Code:**

N =10; % number of samples

%% unit impulse

x_1 = 0; % x(-1)

x0 = 1;

for n = 1:N-1

x(n) = 0;

end

d = 1;

% in MATLAB index zero won’t exist

% d is for adjusting MATLAB index

% so in below line y(0+d) is true value of y(0)

y(0+d) = 1; % Initial condition assumption

%% impulse response

y(1+d) = -0.75*y(0+d)+ x(1) – 0.3*x0 – 0.4*x_1;

y(2+d) = -0.75*y(1+d)+ x(2) – 0.3*x(1) – 0.4*x0;

for n=3:N-1

y(n+d)= -0.75*y(n-1+d) + x(n) – 0.3*x(n-1) – 0.4*x(n-2);

end

y

%% Filter

b = [ 1 -0.3 -0.4]; %

a = [1 0.75]; %

X = [1, zeros(1,N-1)];

Y = filter(b,a,X)

% subplot(2,1,1)

% plot([0:N-1],y)

% title(‘equation response’)

% subplot(2,1,2)

% plot([0:N-1],Y)

% title(‘filter output’)

**Output:**

Response from equation

Responsefrom filter()