# Approximate the magnitude response of an analog filter with a digital filter, starting from its gain expression

I have an analog filter with its frequency response curve in dB described by the following expression: $$N_{dB}=20log_{10}\omega t_1 \sqrt{\frac{1+(\omega t_2)^2}{1+(\omega t_1)^2}}$$ This expression is derived from the series connection of two lowpass filters each associated with the following RC circuit:

where, for each circuit, the time constant $t_i=RC$ and of course $\omega = 2\pi f$, where $f$ is the frequency (this is actually the equalization curve for magnetic tape recording/playback, see Annex B, page 14 of this document).

I would like to obtain an approximation of this frequency response using a digital filter. I don't know if there is a method to exploit our knowledge of the analog frequency response or if I should design the filter myself from scratch. The end goal is to obtain the impulse response and save it as a a .wav file (I know how to do this last part). I just took a basic DSP course at my Uni but we didn't work with analog filters so I am a little bit lost.

• This is the (log of the) magnitude of the frequency response of an analog filter, I suppose? And I guess you want a digital filter approximating this magnitude response of the analog filter (?) Mar 21 '14 at 8:25
• Exactly, I forgot to specify that this is an analog filter (it actually is the equalization curve for magnetic tape playback, see this document, Annex B, page 14. What I want to do is, a you suggested, approximate the magnitude response with a digital filter, that I know how to manipulate. Mar 21 '14 at 9:16

From the given magnitude response (and from what is written in the document), the transfer function of your system is

$$H(s)=\frac{st_1(1+st_2)}{1+st_1}\tag{1}$$

Note that this system is not stable. I suppose that this response is only to be approximated in a certain frequency range, which means that a stable filter can approximate this transfer function well enough in that frequency range.

There are several methods for transforming an analog transfer function to the digital domain. You could use the bilinear transform, which will give you a recursive digital filter. This filter will have a pole at $$z=-1$$ (i.e. it will not be stable), but you could move this pole away from the unit circle (e.g. to $$z=-.98$$, just try a few values), and this will probably result in a useful system. Another method is frequency sampling. You replace $$s$$ in (1) by $$j\omega$$ and evaluate $$H(j\omega)$$ on an equidistant frequency grid in the range $$[0,f_s/2]$$ where $$f_s$$ is your sampling frequency. Then you extend your desired frequency response to the range $$[0, f_s]$$ by taking the conjugate symmetry property of the DFT into account. Then you simply obtain the impulse response by applying an inverse FFT to the desired frequency response.

• The bilinear transform method looks like it could work, we briefly saw it in one of the lectures so I can dig up the slides. I don't know exactly which value should $T$ assume, for the moment I'll just use $T=2$ as we saw in class. One last thing: I found another expression for the filter gain which seems to be the inverse of the first one I provided (apart from some normalization factors): $N_{dB}=10log_{10}[1+\frac{10^{12}}{(2\pi f t_1)^2}]-10log_{10}[1+10^{-12}(2 \pi f t_2)^2]$ This one seems to make more sense; what would the transfer function be in this case? Thanks for your help! Mar 21 '14 at 11:43
• Yes, this is the inverse (plus some constants). Just swap numerator and denominator in formula (1) of my answer and you have the transfer function (just get the constants right). Mar 21 '14 at 11:49
• It isn't clear from the diagram exactly how the components connect, but will all passive components the transfer function will be stable. Mar 21 '14 at 14:09
• Yes, but the given frequency response does not correspond to a stable system. Its magnitude is unbounded as $\omega$ increases. Mar 21 '14 at 15:00
• So I would check the math that resulted in the given transfer function. It wouldn't make a lot of sense to do frequency analysis on an unstable system (unless this is a control system problem). I suspect this is a "sloppy" 2nd order lowpass filter of the form H(S) = 1/aS^2+bS+C) resulting from the cascade of two first order circuits. A proper circuit diagram would help. The simulation suggestion using the bi-linear transform is fine though. Mar 21 '14 at 15:25

Did you try to plot this curve in matlab. I am not sure whether it is any standard high,low or band pass filter. So, to calculate the impulse response there might be two ways. 1. take the inversefft of the NdB and then do the convolution between your impulse input and the inversefft signal of filter usinc conv(x,y) command. 2. Or convert the impulse input into frequency domain by fft transform in matlab and then just multiply the gain and fft of input impulse and then convert them in time domain. Can you do it using above method? Do you want a matlab code for this method?

• I edited the answer providing details on the kind of filter I want to implement. The issue here is that I know how to work with digital filters, but not with analog filters, and in this case I need a method to approximate the frequency response of the analog filter with a digital one. I hope it's clearer now. I understand both the solutions you provided, but how can I represent the analog filter in Matlab in order to convolve it with the impulse input (if such a thing is even possible, considering that I need a digital implementation)? Mar 21 '14 at 10:30
• Yeah Now it is clear, So I just guess link Or there is one more method link I could find. you can try these... hopefully you get your response... Mar 21 '14 at 11:46