2
$\begingroup$

Does anyone know of a way to design a filter with arbitrary magnitude and phase response in Matlab?

$\endgroup$
  • $\begingroup$ also, if your filter is causal, you can't do whatever magnitude and phase you want. you might have to toss is some constant delay or linear-phase term in the phase, just to get a causal impulse response. if it's causal, then $\Re\left\{H[k]\right\}$ and $\Im\left\{H[k]\right\}$ are a Hilbert transform pair. $\endgroup$ – robert bristow-johnson May 4 '15 at 1:22
  • $\begingroup$ What do you actually mean by arbitrary magnitude and phase response, do you mean that you can specify the filter in the frequency domain as a function, or only specify a finite number of points? $\endgroup$ – fibonatic Jun 3 '15 at 3:04
3
$\begingroup$

for FIR, the simplest way is to inverse FFT you two-sided complex frequency response:

$$ h[n] = \operatorname{iFFT} \left\{ H[k] \right\} $$

(use a Kaiser window to window the FIR to a length that is acceptable to implement.)

i presume you have access to firpm( ) and/or firls( ).

so first divide your complex frequency response into real and imaginary parts:

$$ H_r[k] = |H[k]| \cos\left(\arg\{H[k]\} \right) $$ $$ H_i[k] = |H[k]| \sin\left(\arg\{H[k]\} \right) $$

send both $H_r[k]$ and $H_i[k]$ to the Parks-McClellan or Least Squares optimal FIR designer, but set ftype to 'hilbert' for $H_i[k]$.

sum the two resulting real-valued FIRs to get your result.

lastly, if you want to design an IIR to an arbitrary magnitude and phase spec, then that's a much bigger problem and consideration. maybe use Prony to design to your impulse response $h[n]$ or use Matt's dissertation that i first learned of now, or use Greg Berchin's FDLS. i dunno. no quick solution for you there.

$\endgroup$
  • $\begingroup$ I'm trying to find more information on the method that devides the response in real and imaginary parts and designs filters for them separately. It sounds promising for my application but I wonder what this technique is called and why it works. $\endgroup$ – TheSlowGrowth Aug 20 '18 at 11:39
2
$\begingroup$

There's a PhD thesis with exactly this phrase in its title (including Matlab programs):

Algorithms for the Constrained Design of Digital Filters with Arbitrary Magnitude and Phase Responses

$\endgroup$
  • $\begingroup$ at first i thought it was in Deutsche (it's not, thankfully for me) but the next obstacle is reading it without reading it online. do you have it in .pdf, Matt? $\endgroup$ – robert bristow-johnson May 4 '15 at 0:56
  • $\begingroup$ @robertbristow-johnson: If you follow the link in the answer you'll see the abstract, but above it there's a download link for the pdf version. $\endgroup$ – Matt L. May 4 '15 at 9:56
  • $\begingroup$ I know I'm a bit slow: Matt, I didn't know you were one of Prof. Mecklenbr􏰏äuker's students! Cool! :-) $\endgroup$ – Peter K. Sep 1 '15 at 11:23
  • $\begingroup$ @PeterK.: I was indeed. You know him? (Maybe this is not the place to discuss such things, but anyway ...) $\endgroup$ – Matt L. Sep 1 '15 at 12:08
  • 1
    $\begingroup$ @PeterK.: Yes, Franz Hlawatsch was a colleague of mine. As you know he has quite some name in time-frequency analysis, but he's been doing more work in digital communications in the past years. $\endgroup$ – Matt L. Sep 1 '15 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.