So I took this digital LPF from some website:
And tried implement it first in MatLab to see how it goes, here's the code used:
x=[0 0 0 0 0 0 0 0 0 0 0];
y=[0 0 0 0 0 0 0 0 0 0 0];
t = linspace(0,1,100);
%a = sin(2pi0.1*t)
%plot(t,a)
yy = zeros(1, 100);
for c= 1:100
x(1) = sin(2pi1000t(c));
y(1) = ((1.x(1)+2.x(2)+ 1.x(3)) + 1.789.y(2) -0.948.y(3))./4.841;
yy(c) = y(1);
for i = 1:10
x(i+1) = x(i); % store xi
y(i+1) = y(i); % store yi
end
end
plot(t,yy)
Got this for a sine with 100Hz frequency :
Sine with 1000Hz frequency:
It's just not working as intended. What am i doing wrong?
Edit:
New sampling frequency of 1000Hz
New code used:
x=[0 0 0 0 0 0 0 0 0 0 0];
y=[0 0 0 0 0 0 0 0 0 0 0];
t = linspace(0,1,1000);
%a = sin(2pi0.1*t)
%plot(t,a)
yy = zeros(1, 1000);
for c= 1:1000
x(1) = sin(2pi10t(c));
y(1) = ((1.x(1)+2.x(2)+ 1.x(3)) + 503.273.y(2) -231.158.y(3))./276.115;
yy(c) = y(1);
for i = 1:10
x(i+1) = x(i); % store xi
y(i+1) = y(i); % store yi
end
end
plot(t,yy)
The signal appears to be already attenuated at a frequency if 10Hz, how is that possible?




