Analytic solution for non-flat filter design I'm trying to write an accelerometer calibration script that uses filters to convert from volts into $m/s^2$.  As accelerometers tend to have non-flat response curves, this means I have to design a rather complex filter.  I'm not worried about phase, as I can just apply the filter twice in opposing directions to correct for any phase offsets (like matlab's filtfilt), so the focus is on designing a filter that approximates a user-provided magnitude curve.

Ideally, the user provides a calibration curve as input into an analytic algorithm to solve for the best fitting filter poles.

I'm aware MATLAB has a filter design function, but I don't know what the underlying algorithm is (if its an optimizer, or a closed form solution).

So my question is...


Is there an analytic solution to my filter design problem?  Or do I have to use optimisation scripts to get the best filter?


I'm not mentioning programming language here, as I want to understand the underlying math behind this.
If you are not concerned on the phase and just want to approximate a magnitude response, then your first option should be the frequency sampling method implemented in Matlab/Octave fir2() function.

You would provide the frequency grid and corresponding frequency response magnitude at those frequencies.

As you have also mentioned, least-squares approach is another alternative. Indeed by using suitable weights, you can distribute the error according to your priority cirteria.

Magnitude approximation based on LMS adaptive system identification is also a possible option.