I'm seeking a good advice for a filter. Can you help me?
Right now I made my own simple filter. Not sure what I'm doing, but it seems to work.
function testFilter (t, y, p)
% Forward filtering
% Do first filtering by jumping k/2 elements in the future
l = length(t);
ye = y;
for i = 1:l
sum = 0;
k = 0;
for j = 0:p-1
if(i + j <= l)
sum = sum + ye(i + j);
k = k + 1;
end
end
if(k != 0)
ye(i+floor(k/2)) = sum/k;
end
end
% Do the first p elements!
for i = p:-1:1
sum = 0;
for j = 1:i
sum = sum + ye(j);
end
ye(i) = sum/i;
end
% Done!
figure
plot(t, ye, t, y);
legend("Filtered", "Noisy")
end
It's some kind of moving average, ich. The reason why I selected this is beacuse a low pass filter caused phase shift and I don't like that.
Here is a plot that shows a example how my filter algorithm works. I think it's OK, but can it be done better without phase shift? Do you think Fast Fourier Transform is a much better filter in this noisy case?
If there is no filter that cause phase shifting, can you recommend a good filter for me then with low phase shift?