I want to compare the performance of a Wiener Filter and the Kalman filer to estimate the value of a constant $d$ using mesurements corrupted by a white noise. That is, my measurements are of the form $$x(n) = d + v(n)$$ where $v(n)$ have a normal distribution with mean $0$ and known variance $\sigma^2$.
Using the Kalman filter, I could put it on State Space form $$d(n+1) = d(n)$$ $$x(n) = d(n) + v(n)$$ and solve the problem. But I am having difficults to set the problem so I can solve with the Wiener filter. My desided signal is the constant signal $x$. My filter input is the measurements $x$. But I have doubts if I am doing something wrong, because my estimated signal is not a really good estimative of the desired response. I used the following matlab code:
function test() n = 0:511; d = 10 * ones(1,512); v = 0.5*randn(1,512); x = d + v; w = WienerFIRFilter(x, d, 12); y = filter(w', 1, x); plot(x) hold on plot(y, 'r') end
The function WienerFIRFilter is defined as following
function w=WienerFIRFilter(u,d,M) aux = xcorr(d,u,'biased'); p = aux(1,(length(aux)+1)/2:((length(aux)+1)/2)+M-1); [U, R] = corrmtx(u,M-1); w=inv(R)*p'; end
Am I doing something wrong?