How to design a digital IIR to match the frequency resp of a measured analog filter

7 views (last 30 days)
Hello and thanks for reading!
I ask this question because I'm getting frustrated from hours of trying to work this out:
- I have measured the frequency response from an electric device (audio field) with a quite complex frequency response (several peaks/notches) plus some possible small noise/error in the measure itself.
- I need to match this magnitude response with a IIR filter. Of course it shouldn't perfectly match, but just match peaks/notches positions, so a "smoothed" version of the measure.
- I tried yulewalk and invfreqz with no success. The outcome is totally different from the freq response to match. First I needed to interpolate the measured freq resp down to 0Hz, and it was not easy (giving that the measure is logspaced). I did it manually because interpolation was not accurate, and I did it with a jump from 20Hz to 0, because the matlab commands require the frequencies to reach 0 but with a log-spaced measured frequency response you will go to zero at infinity.
- with yulewalk I had no good outcome. With invfreqz I got something vaguely similar to the freq response I need, but I found a bug: the b,a coefficients out of invfreqz are swapped, so that to obtain the right freqz plot I have to do this:
>> [b,a] = invfreqz(allon_int[0;allon(:,1)]/max(allon(:,1))*pi,1,24,wt); figure, freqz(b,a);
- Anyway with invfreqz I'm trying to mingle with the weighting vector wt, the order of the IIR, and even the iterations of the algorithm but I get most of the times totally wrong magnitude responses and the warning: Warning: Matrix is close to singular or badly scaled.
Any help would be appreciated. For examples: how to improve the frequency response to be matched? Should I make it smoother? Or create a vector with only the peaks and notches to be matched (and another one with their frequencies)?
Thanks for reading, any advice will be great!

Accepted Answer

Honglei Chen
Honglei Chen on 6 Sep 2011
Hi Alfredo,
If you have access to Signal Processing Toolbox, you could try to use one of fdesign.arbmag. You an also try fdesign.arbmagnphase if you are interested in matching phase and have access to either Filter Design Toolbox or DSP System Toolbox. The following demo may also be helpful
HTH

More Answers (5)

Alfredo
Alfredo on 6 Sep 2011
If you want to challenge yourself in the work: the frequency response (first row is the freq points, second row is the magnitude values in dB):
meas_f_resp = [20,21.4250000000000,22.9750000000000,24.6000000000000,26.3750000000000,28.2500000000000,30.2750000000000,32.4250000000000,34.7500000000000,37.2500000000000,39.9000000000000,42.7500000000000,45.8250000000000,49.1000000000000,52.6000000000000,56.3750000000000,60.4000000000000,64.7250000000000,69.3500000000000,74.3000000000000,79.6250000000000,85.3250000000000,91.4250000000000,97.9500000000000,104.950000000000,112.475000000000,120.500000000000,129.125000000000,138.375000000000,148.250000000000,158.875000000000,170.225000000000,182.400000000000,195.450000000000,209.500000000000,224.500000000000,240.500000000000,257.750000000000,276,295.750000000000,317,339.750000000000,364,390,417.750000000000,447.750000000000,479.750000000000,514,550.750000000000,590.250000000000,632.500000000000,677.750000000000,726.250000000000,778,833.750000000000,893.250000000000,957.250000000000,1025.75000000000,1099,1177.75000000000,1262,1352.25000000000,1448.75000000000,1552.50000000000,1663.50000000000,1782.50000000000,1910,2046.50000000000,2192.50000000000,2350,2517.50000000000,2697.50000000000,2890,3097.50000000000,3320,3557.50000000000,3810,4082.50000000000,4375,4687.50000000000,5025,5382.50000000000,5767.50000000000,6180,6622.50000000000,7097.50000000000,7605,8147.50000000000,8730,9355,10022.5000000000,10740,11510,12332.5000000000,13215,14160,15172.5000000000,16257.5000000000,17420,18665,20000;-60.9775772515000,-60.4170027795000,-59.7907564750000,-58.8571422773000,-58.6107074678000,-58.0211797610000,-57.4336304548000,-56.8833197267000,-56.3323785420000,-55.7933787438000,-55.1878451388000,-54.7506074018000,-54.2306273568000,-53.2165631485000,-53.2323663974000,-52.7972894479000,-52.3731850629000,-51.9601489463000,-51.5722922391000,-51.2318727347000,-50.9102487399000,-50.6116144240000,-50.3507913523000,-50.1084299446000,-49.8938201481000,-49.7154804003000,-49.5560074109000,-49.4219671469000,-49.3122386867000,-49.2431263841000,-49.1550681737000,-49.1065299661000,-49.0582614916000,-49.0390289576000,-49.0294286365000,-49.0198389147000,-49.0198389147000,-49.0294286365000,-49.0486399014000,-49.0582614916000,-49.0775367054000,-49.1065299661000,-49.1259127126000,-49.1453388087000,-49.1550681737000,-49.1745596593000,-49.1550681737000,-49.1065299661000,-49.0102597688000,-48.8678260283000,-48.6446814561000,-48.3203585566000,-47.8975200751000,-47.3824682005000,-46.7769880485000,-46.1350131680000,-45.4860414510000,-44.8703088228000,-44.3120565950000,-43.8454422956000,-43.4934558086000,-43.2434489214000,-43.0823005983000,-43.0100281832000,-43.0196298309000,-43.1113787885000,-43.3276463727000,-43.6883931541000,-44.2953502786000,-45.2842182717000,-46.9263300406000,-49.5738664941000,-53.6424859040000,-54.7552435853000,-51.0272018950000,-48.1887184066000,-46.4714867113000,-45.4098071524000,-44.7112814818000,-44.2454232647000,-43.9143888126000,-43.6728432953000,-43.4934558086000,-43.3625545451000,-43.2533122464000,-43.1649429588000,-43.0968275251000,-43.0388650268000,-42.9908566712000,-42.9431122077000,-42.9145909957000,-42.8767078134000,-42.8389891398000,-42.8154978757000,-42.7873919658000,-42.7640396473000,-42.7407499440000,-42.7221630392000,-42.7036158235000,-42.6804873592000,-42.6620288274000;];

Wayne King
Wayne King on 6 Sep 2011
Hi Alfredo, You say you have measured the frequency response. Have you measured the complex-valued response (magnitude and phase), or do you just have the magnitude?
By your use of invfreqz() I would assume that you have the complex-valued response, but then you reference the magnitude response in your post, so I'm not sure what you have to begin with?
Wayne

Alfredo
Alfredo on 7 Sep 2011
Thanks, @Waine: I just have a real-valued mag response. Is not invfreqz suited to a real-valued frequency response? @Honglei: I'll try that out and report the outcome Cheers

Wayne King
Wayne King on 7 Sep 2011
Hi Alfredo, invfreqz expects the complex-valued frequency response. If you only have the magnitude then a suggestion close to Honglei's is fdesign.arbmag. If you have the DSP System Toolbox, then Honglei's demo suggestion is a great place to start. You can still use fdesign.arbmag if you do not have DSP but have the Signal Processing Toolbox. However, you will not have access to all the specifications. See the reference page for fdesign.arbmag for details.

Alfredo
Alfredo on 7 Sep 2011
fdesign.arbmag worked out very well after I linearly resampled with spline() the frequency response. Thanks!!

Products

Community Treasure Hunt

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

Start Hunting!