xcorr function with impulse response

956 views Asked by At

I'm trying to design a Wiener filter in Matlab for a deconvolution problem but I'm having a lot of problems. I have a gaussian white noise process with a variance of 1.2 and a impulse response which has length two. Its values are g(0) = 5 and g(1) = 4. Later on in the process I try to determine Rxx(m). For this I need to calculate g(m)*g(-m) (convolution) and have been advised to use the xcorr function in Matlab but my results don't make sense. Can anyone help me with this xcorr function and with advice on how to use this impulse response in this? I have tried working with the fourrier transforms of g but this has been no help.

1

There are 1 answers

3
Matt On BEST ANSWER

The following code implements only a part of what I can see in the description. It generates the noise processes and does what is described in the first part. The autocorrelation is not calculated with the filter coefficients but with the actual signal.

% generate noise process y
y = randn(1,N) * sqrt(1.2);

% filter y with the fir-filter g
g = [2, 0.6];
r = filter(g,1,y);

% generate noise process d
d = randn(1,N) * sqrt(0.2);

% x is the sum of r and d
x = r + d; 

% autocorrelation of x
[Rxx,lagRxx] = xcorr(x);

% plot autocorrelation
figure; grid on;
plot(lagRxx,Rxx);
title('Biased Autocorrelation of Signal x');
xlabel('Lag');

% cross correlation between x and y
[Rxy,lagRxy] = xcorr(x,y);

% plot crosscorrelation
figure; grid on;
plot(lagRxy,Rxy);
title('Biased Crosscorrelation of Signal x and y');
xlabel('Lag');