passive RC highpass magnitude FRF to MATLAB FIR coefficients

4 views (last 30 days)
Hello,
I have a GRASS EEG LP511 amplifier. It has a high-pass filter that is described as passive with 12 dB/octave slope. I imagine it is something like two simple RC high-pass filters in series. I can measure the magnitude frequency response function easily and I know the cut-off frequency (-6dB at 3 Hz).
I would like to implement this as an FIR filter in MATLAB.
I am having trouble sorting out how to obtain the FIR filter coefficients to match my analogue high-pass filter.
Could anyone help? Please assume I don't have a strong enough background and will need thorough explanations. Many Thanks! DP

Accepted Answer

Star Strider
Star Strider on 4 Aug 2023
I generally don’t design filters with such specificity, and so usually use relatively straightforward command-line functions. To design a filter such as yours, I would use the designfilt function (introduced in R2014a). It has a number of arguments, as well as ‘Filter Designer’, a GUI interface that can make this easier. (If you use Filter Designer, click on the ‘File’ tab and then click on ‘Generate MATLAB Code’ to use the filter code wtih the filtfilt function and your signal.) Use filtfilt to do the actual filtering regardless of how you design and code the filter.
  6 Comments
David W Purcell
David W Purcell on 16 Aug 2023
Again, your help has pointed me in the direction of achieving what I needed! Thank you! I will accept your answer as it answers the FIR question that I originally posted.
With your guidance, I learned what my actual need was and how to solve it. My analogue GRASS filter's measured amplitude response very closely matches an analogue second order highpass system. The function invfreqs that you mentioned above would allow me to use meaurements of amplitude and phase to estimate the s-domain filter coefficients and then I could convert those to z-domain.
mag=labAmp; %measured system amplitude response; using variable name from MATLAB documentation
phase=labPhaseDeg*pi/180; %measured system phase response; deg to rad
w=labFreq*2*pi; %Hz to rad/s; measurement frequencies
h=mag.*exp(1j*phase); %complex response (the transfer function)
[bdat,adat] = invfreqs(h,w,2,2,[],4); %s-domain filter coefficients
However, since the model of a second order high pass system was so good, I decided to directly use that to compute analogue s-domain filter coefficients and then convert those to digital z-domain coefficients for use with the filter function (to obtain the phase response too). I include some code bits below in case they help future readers.
b=[ 1 0 0 ]; w0=3*2*pi; %3Hz cutoff a=[ 1 2*w0 w0^2 ]; %highpass filter coef. with 3 Hz cutoff
[h,w]=freqs(b,a, measuredFreq*2*pi); %model frequency response
[bd,ad]=bilinear(b,a,fs); %convert analogue filter coef. to digital
Numerator coef. in bd, and denominator coef. in ad, can be used with filter(bd, ad, y) to reproduce the filtering characteristics of my real world GRASS LP511 Amp's highpass filter with cutoff 3 Hz.

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!