forked from simonweiler/LGN_Aanalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlowpassfilt.m
More file actions
18 lines (16 loc) · 796 Bytes
/
lowpassfilt.m
File metadata and controls
18 lines (16 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function filtered = lowpassfilt(signal, order, fc, fs, type)
%LOWPASSFILT Switchboard for ML lowpass bessel and butterworth filters
% filtered = LOWPASSFILT(signal, order, fc, fs, type) filters the input
% signal at a cutoff freqeuency (fc, in Hz) of sampling rate (fs) using either a Bessel (type = 'Bessel') or
% Butterworth (type = 'Butter') filter of 'order' order (aka pole).
% Tobias Rose 2019
if nargin < 5
type = 'Bessel';
end
if type == 'Butter'
[b,a] = butter(order,fc/(fs/2), 'low');
elseif type == 'Bessel'
[b,a] = besself(order,fc * 2 * pi(), 'low');
[b,a] = bilinear(b,a,fs); % digital to analog conversion (besself is analog only)
end
filtered = filtfilt(b,a,signal); % bidirectional filtering w/o phase distortion