I'm new to Matlab, so this is probably a really dumb question. I'm trying to design an FIR where I can set the points. I want a symmetric FIR. I'm assuming that an N tap FIR gives me N/2 degrees of freedom for an even number of taps, and (N + 1)/2 degrees of freedom for an odd number of taps. This should allow me to set the frequency response at a number of points equal to the degrees of freedom, and have the frequency response travel through these points exactly. If I don't specify transitions that are too sharp relative to the number of taps, then the frequency response should be reasonably well controlled between the set points. I had assumed that I could use the filter toolbox's freqsamp method to do this, but it doesn't seem to work as I expected. What am I doing wrong? I'd normally do this in Mathematica or C, but I'm trying to get into the spirit of Matlab. I would want to solve the point setting problem anyway, but perhaps there's an easier way to do the immediate task that I wanted it for. I want to implement a Butterworth amplitude response in an FIR filter (to emulate some legacy equipment) but I can't find an easy way of doing that in Matlab (hence the point setting experiments). Thanks Pete

# Filter design with 'freqsamp' method?

Started by ●June 30, 2010

Reply by ●June 30, 20102010-06-30

Pete Fraser wrote:> I'm new to Matlab, so this is probably a really dumb question. > I'm trying to design an FIR where I can set the points. > I want a symmetric FIR. > I'm assuming that an N tap FIR gives me N/2 degrees of freedom > for an even number of taps, and (N + 1)/2 degrees of freedom > for an odd number of taps. > This should allow me to set the frequency response at a > number of points equal to the degrees of freedom, and > have the frequency response travel through these points > exactly. If I don't specify transitions that are too sharp > relative to the number of taps, then the frequency response > should be reasonably well controlled between the set points. > > I had assumed that I could use the filter toolbox's freqsamp > method to do this, but it doesn't seem to work as I expected. > What am I doing wrong? I'd normally do this in Mathematica > or C, but I'm trying to get into the spirit of Matlab. > > I would want to solve the point setting problem anyway, but > perhaps there's an easier way to do the immediate task that > I wanted it for. I want to implement a Butterworth amplitude > response in an FIR filter (to emulate some legacy equipment) > but I can't find an easy way of doing that in Matlab (hence the > point setting experiments).But why would anyone want to emulate Butterworth magnitude response in a linear phase FIR filter whereas it is very straightforward to do the (**exact) Butterworth as IIR filter? ** frequency warping Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com

Reply by ●June 30, 20102010-06-30

"Vladimir Vassilevsky" <nospam@nowhere.com> wrote in message news:0Jidnc3knONVbbbRnZ2dnUVZ_oSdnZ2d@giganews.com...> But why would anyone want to emulate Butterworth magnitude response in a > linear phase FIR filter whereas it is very straightforward to do the > (**exact) Butterworth as IIR filter?Butterworth will be one of several possible responses from the same hardware. I'd rather not deal with Butterworth's phase issues. Pete

Reply by ●June 30, 20102010-06-30

On 6/30/2010 10:06 PM, Pete Fraser wrote:> "Vladimir Vassilevsky"<nospam@nowhere.com> wrote in message > news:0Jidnc3knONVbbbRnZ2dnUVZ_oSdnZ2d@giganews.com... > >> But why would anyone want to emulate Butterworth magnitude response in a >> linear phase FIR filter whereas it is very straightforward to do the >> (**exact) Butterworth as IIR filter? > > Butterworth will be one of several possible responses > from the same hardware. > > I'd rather not deal with Butterworth's phase issues.What is so good about a Butterworth amplitude response that you want to imitate it? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●June 30, 20102010-06-30

On 06/30/2010 06:21 PM, Pete Fraser wrote:> I'm new to Matlab, so this is probably a really dumb question. > I'm trying to design an FIR where I can set the points. > I want a symmetric FIR. > I'm assuming that an N tap FIR gives me N/2 degrees of freedom > for an even number of taps, and (N + 1)/2 degrees of freedom > for an odd number of taps. > This should allow me to set the frequency response at a > number of points equal to the degrees of freedom, and > have the frequency response travel through these points > exactly. If I don't specify transitions that are too sharp > relative to the number of taps, then the frequency response > should be reasonably well controlled between the set points. > > I had assumed that I could use the filter toolbox's freqsamp > method to do this, but it doesn't seem to work as I expected. > What am I doing wrong? I'd normally do this in Mathematica > or C, but I'm trying to get into the spirit of Matlab. > > I would want to solve the point setting problem anyway, but > perhaps there's an easier way to do the immediate task that > I wanted it for. I want to implement a Butterworth amplitude > response in an FIR filter (to emulate some legacy equipment) > but I can't find an easy way of doing that in Matlab (hence the > point setting experiments).Make a vector that "draws" the frequency response that you want, then take its FFT. It may not be the entirely kosher way to do it, but it certainly works. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html

Reply by ●July 1, 20102010-07-01

Tim Wescott <tim@seemywebsite.com> wrote:>Make a vector that "draws" the frequency response that you want, then >take its FFT. > >It may not be the entirely kosher way to do it, but it certainly works.Doesn't this give you a complex filter? Can you just take the real part afterwards? Steve

Reply by ●July 1, 20102010-07-01

On Jun 30, 10:39�pm, Tim Wescott <t...@seemywebsite.com> wrote:> On 06/30/2010 06:21 PM, Pete Fraser wrote: > > > > > I'm new to Matlab, so this is probably a really dumb question. > > I'm trying to design an FIR where I can set the points. > > I want a symmetric FIR. > > I'm assuming that an N tap FIR gives me N/2 degrees of freedom > > for an even number of taps, and (N + 1)/2 degrees of freedom > > for an odd number of taps. > > This should allow me to set the frequency response at a > > number of points equal to the degrees of freedom, and > > have the frequency response travel through these points > > exactly. If I don't specify transitions that are too sharp > > relative to the number of taps, then the frequency response > > should be reasonably well controlled between the set points. > > > I had assumed that I could use the filter toolbox's freqsamp > > method to do this, but it doesn't seem to work as I expected. > > What am I doing wrong? I'd normally do this in Mathematica > > or C, but I'm trying to get into the spirit of Matlab. > > > I would want to solve the point setting problem anyway, but > > perhaps there's an easier way to do the immediate task that > > I wanted it for. I want to implement a Butterworth amplitude > > response in an FIR filter (to emulate some legacy equipment) > > but I can't find an easy way of doing that in Matlab (hence the > > point setting experiments). > > Make a vector that "draws" the frequency response that you want, then > take its FFT. > > It may not be the entirely kosher way to do it, but it certainly works.Pete might want to use the "window method". with an iFFT *larger* than N, draw in the frequency response, he'll get an impulse response that is longer than N, then window it to length N. (then maybe FFT back to see how bad the window mangled things.) r b-j

Reply by ●July 1, 20102010-07-01

On 06/30/2010 08:10 PM, Steve Pope wrote:> Tim Wescott<tim@seemywebsite.com> wrote: > >> Make a vector that "draws" the frequency response that you want, then >> take its FFT. >> >> It may not be the entirely kosher way to do it, but it certainly works. > > Doesn't this give you a complex filter? > > Can you just take the real part afterwards?If the desired magnitude response is real and symmetric around the frequency = 0 bin (element 1 in Matlab's indexing scheme) then the FFT will be largely real, with only leftover numerical noise in the imaginary part. If the imaginary part has any weight to it at all, then you've done something wrong. Note that you want to be symmetric around frequency = 0 modulo the whole thing; i.e. for a 256 element vector element 2 should equal element 256 with Matlab-style indexing, element 3 should equal element 255, etc. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html

Reply by ●July 1, 20102010-07-01

Tim Wescott <tim@seemywebsite.com> wrote:>On 06/30/2010 08:10 PM, Steve Pope wrote:>> Tim Wescott<tim@seemywebsite.com> wrote:>>> Make a vector that "draws" the frequency response that you want, then >>> take its FFT.>>> It may not be the entirely kosher way to do it, but it certainly works.>> Doesn't this give you a complex filter?>> Can you just take the real part afterwards?>If the desired magnitude response is real and symmetric around the >frequency = 0 bin (element 1 in Matlab's indexing scheme) then the FFT >will be largely real, with only leftover numerical noise in the >imaginary part. If the imaginary part has any weight to it at all, then >you've done something wrong.That makes sense. Thanks. Steve

Reply by ●July 1, 20102010-07-01

"Jerry Avins" <jya@ieee.org> wrote in message news:BdTWn.3387$OU6.1391@newsfe20.iad...> What is so good about a Butterworth amplitude response that you want to > imitate it?Nothing. It's just that, under some circumstances, equipment that is later in the signal chain expects a Butterworth response.