# How can I plot Wiener filter's behaviour for different taps (memory filter)?

What's the expected behaviour of Wiener Filter for different taps (memory filter) , when input signal is a sinusodial tone?

Do you have any idea how I can plot or simulate Wiener Filter's behaviour (estimation basically) for different value of parameter M ? I hope my imlementation is correct. M is the filter's memory am I right ?

That's my code for Wiener Filter

clc;
close all;
clear all;

T = 1; % total recording time
fs = 500; % sampling frequency
N = fs * T; % samples
tt = (0:N-1) / fs; % time vector
fc = 10; % frequency

d = sin(2 * pi * fc * tt); % desired signal X
figure;
plot(d);

mu_w = 0;
sigma2_w = 5;

w = mu_w +sqrt(sigma2_w) * 0.5 * randn(1, N); % additive gaussian noise W * 0.5 to reduce effect
x = d + w; % signal corrupted with noise Y
l = d - x;

rr = [];
k = 1;
r = xcorr(x);
M = 25; % taps filter memory

for i = 1:1:M
rr(i) = r(N-i+1);
end

R = toeplitz(rr);
I = inv(R);
p = xcorr(d, x);

for i = 1:1:M
P(i) = p(N-i+1);
end

W = (inv(R)) * P';
k = 1;
y = zeros(N, 1);

for i = M:N
j = x(i:-1:i-M+1);
y(i) = (W)' * (j)';
ylim([-5 5])
end

e = y' - d; % error signal


Only action needed is to change the value of M and study the plot .