ruohoruotsi / Butterworth-Filter-Design

C++ classes for designing high-order Butterworth IIR & equalization filters
GNU General Public License v3.0
163 stars 42 forks source link

[Question] How to translate this matlab code using your library. #4

Closed yqrashawn closed 7 years ago

yqrashawn commented 7 years ago

I'm newb in matlab and c++.

%% High-pass filter linear velocity to remove drift

order = 1;
filtCutOff = 0.1;
[b, a] = butter(order, (2*filtCutOff)/(1/samplePeriod), 'high');
linVelHP = filtfilt(b, a, linVel);

a,b are vectors linVel linVelHP are vectors

ruohoruotsi commented 7 years ago

Hi, this library is really for designing high-order Butterworth IIR & equalization filters. By high-order, I mean more than order 6. If you only need order 1, high pass with a very low cutoff, basically a DC-offset or DC-removal filter. You can do so simply with the following simple one-zero, one pole implementation, as this library is definitely overkill. Cheers.

y = x - xm1 + 0.995 * ym1;
xm1 = x;
ym1 = y;

Please refer to

ruohoruotsi commented 7 years ago

okay, closing now 👍