# Matlab code to determine and plot impulse response

I have a signal y[n], represented by the vector y in this form

• y[n] =x[n] + ax[n−N]

1. x[n] is the uncorrupted speech signal which has been delayed by N samples and added back in with its amplitude decreased by a<1
2. N= 1000, and the echo amplitude,a= 0.5.

I need help with: Determining and plotting the impulse response of the signal. Also I was hoping to store this impulse response in the vector for 0≤n≤1000

What I have and which does not work:

% Testing the input:
sound(y,8192)

% echotime,N= 1000, and
% the echo amplitude,a= 0.5.
N = 1000;
a = 0.5;

n = [0:1000]; %time vector

for i=0:1000
y(i)=x(i)+a*x(i+N)
end
stem(n,y) %output plot


This would give me an error lie:

Undefined function or variable 'x'.

Error in (line 15)
y(i)=x(i)+a*x(i+N)


Determining and plotting the impulse response of the signal.

You are confusing signals and systems. Systems have impulse responses, signals don't. You can calculate the output signal of a linear time invariant system for any given input vy convolving the input signal with the impulse response of the system.

% create the impulse response
M = 1; % MATLAB indexing offset
N = 1000;
h = zeros(1001,1);
h(M+0) = 1;
h(M+1000) = 1;
stem(h);


You need to create a unit impulse signal to drive your filter in order to see its impulse response. Create an array x[1000] with a 1 in the first location, and 0 everywhere else.

If you pass this signal through your filter, your y array will be the impulse response. But it should be obvious by inspection that it will consist of a 1 in the first location and a×1 in the Nth location, 0 everywhere else.