This repository has been archived on 2023-12-21. You can view files and clone it, but cannot push or open issues or pull requests.
ece45-project/DarellsAnnex/DarellbandpassFilter.m
Darell Chua Yun Da 6c7aa76b62 Continuous Replay and Filter
Continuous Replay and Filter. Added a test main for people to easily test their filters.
2021-12-02 13:44:57 +08:00

20 lines
513 B
Matlab

function output_y = DarellbandpassFilter(y,Fs,LOW,MED,HIGH)
Len = length(y);
F = Fs * (-Len/2 : (Len/2 - 1))/Len ;
Mod_Freq = fftshift(fft(y));
lenf = length(F);
output = 0 .* Mod_Freq; % zero array of len f
for n = 1:lenf
if ((LOW < abs(F(n))) && HIGH > abs(F(n)))
output(n) = 1;
else
output(n) = 0;
end
end
filtered_Mod_Freq = fftshift(Mod_Freq .* output);
output_y = real(ifft(filtered_Mod_Freq));
end