DSPRelated.com
Forums

How to interpret polyphase coefficients generated in MATLAB

Started by vizziee July 6, 2009
> Check your equations. =A0I get > > ( ( (22-1)/2 )/20 + ( (22-1)/2 )/10 + ( (1010-1)/2 )/5 ) =3D 102.4750 > which is consistant with what you are actually getting, not what you > are calculating. > > Also note that the filters you are identifying as half-band filters > are not actually half-band filters. =A0Half-band filters have the > property that almost half of the coefficients are zero, saving > calculations, which may be useful to you. But, among other properties, > the lengths of halfband filters are constrained to {3, 7, 11, 15, 19, > 23, 27, ..., previous+4, ...}, so a filter of length 22 isn't a half- > band filter. > > Dirk Bell
Thanks Dirk. I checked the Halfband filters that I generated in MATLAB. It says it has Direct Form Polyphase Filter structure. The coefficients were generated by specifying 'halfband' option to fdesign.decimator function. The number of generated coefficients for this half-band decimator is actually 21 and I padded a zero to make it 22 for a 2-path polyphase implementation. I did a reading for Half-band filters and what you say about the HalfBand FIR filter coefficients is absolutely true: the number of coefficients should be 3+4n for a non-negative integer n. However I couldn't reconcile the MATLAB halfband filter generated above with this definition. Are halfband decimators different than the Nyquist half-band filters? Also the way you calculated the delay of half-band filters appears very much true. However assuming this is the polyphase implementation of half-band decimators, shouldn't delay be calculated like a standard polyphase filter delay formula: ((No_of_taps-1)/2)/ Decimation_Factor? Thanks again for your insightful replies earlier. I could drastically reduce the no of taps in my current design while also bettering the response. Though the questions as above still linger in my mind. Regards, vizziee.
On Jul 8, 6:44&#4294967295;pm, vizziee <vizz...@gmail.com> wrote:
> > Check your equations. &#4294967295;I get > > > ( ( (22-1)/2 )/20 + ( (22-1)/2 )/10 + ( (1010-1)/2 )/5 ) = 102.4750 > > which is consistant with what you are actually getting, not what you > > are calculating. > > > Also note that the filters you are identifying as half-band filters > > are not actually half-band filters. &#4294967295;Half-band filters have the > > property that almost half of the coefficients are zero, saving > > calculations, which may be useful to you. But, among other properties, > > the lengths of halfband filters are constrained to {3, 7, 11, 15, 19, > > 23, 27, ..., previous+4, ...}, so a filter of length 22 isn't a half- > > band filter. > > > Dirk Bell > > Thanks Dirk. I checked the Halfband filters that I generated in > MATLAB. It says it has Direct Form Polyphase Filter structure. The > coefficients were generated by specifying 'halfband' option to > fdesign.decimator function. The number of generated coefficients for > this half-band decimator is actually 21 and I padded a zero to make it > 22 for a 2-path polyphase implementation. > > I did a reading for Half-band filters and what you say about the > HalfBand FIR filter coefficients is absolutely true: the number of > coefficients should be 3+4n for a non-negative integer n. However I > couldn't reconcile the MATLAB halfband filter generated above with > this definition. Are halfband decimators different than the Nyquist > half-band filters? Also the way you calculated the delay of half-band > filters appears very much true. However assuming this is the polyphase > implementation of half-band decimators, shouldn't delay be calculated > like a standard polyphase filter delay formula: ((No_of_taps-1)/2)/ > Decimation_Factor? > > Thanks again for your insightful replies earlier. I could drastically > reduce the no of taps in my current design while also bettering the > response. Though the questions as above still linger in my mind. > > Regards, > > vizziee.
Vizziee, Would you post the coefficients (or preferably all MATLAB inputs and resulting output) from your halfband design. BTW a halfband filter could have a length 21 if it is really a length 19 filter with a zero added to each end, but that would be a waste of computation if you used the zero coefficients. Dirk Bell DSP Consultant
On Jul 9, 12:47&#4294967295;pm, Dirk Bell <bellda2...@cox.net> wrote:
> On Jul 8, 6:44&#4294967295;pm, vizziee <vizz...@gmail.com> wrote: > > > > > > Check your equations. &#4294967295;I get > > > > ( ( (22-1)/2 )/20 + ( (22-1)/2 )/10 + ( (1010-1)/2 )/5 ) = 102.4750 > > > which is consistant with what you are actually getting, not what you > > > are calculating. > > > > Also note that the filters you are identifying as half-band filters > > > are not actually half-band filters. &#4294967295;Half-band filters have the > > > property that almost half of the coefficients are zero, saving > > > calculations, which may be useful to you. But, among other properties, > > > the lengths of halfband filters are constrained to {3, 7, 11, 15, 19, > > > 23, 27, ..., previous+4, ...}, so a filter of length 22 isn't a half- > > > band filter. > > > > Dirk Bell > > > Thanks Dirk. I checked the Halfband filters that I generated in > > MATLAB. It says it has Direct Form Polyphase Filter structure. The > > coefficients were generated by specifying 'halfband' option to > > fdesign.decimator function. The number of generated coefficients for > > this half-band decimator is actually 21 and I padded a zero to make it > > 22 for a 2-path polyphase implementation. > > > I did a reading for Half-band filters and what you say about the > > HalfBand FIR filter coefficients is absolutely true: the number of > > coefficients should be 3+4n for a non-negative integer n. However I > > couldn't reconcile the MATLAB halfband filter generated above with > > this definition. Are halfband decimators different than the Nyquist > > half-band filters? Also the way you calculated the delay of half-band > > filters appears very much true. However assuming this is the polyphase > > implementation of half-band decimators, shouldn't delay be calculated > > like a standard polyphase filter delay formula: ((No_of_taps-1)/2)/ > > Decimation_Factor? > > > Thanks again for your insightful replies earlier. I could drastically > > reduce the no of taps in my current design while also bettering the > > response. Though the questions as above still linger in my mind. > > > Regards, > > > vizziee. > > Vizziee, > > Would you post the coefficients (or preferably all MATLAB inputs and > resulting output) from your halfband design. > > BTW a halfband filter could have a length 21 if it is really a length > 19 filter with a zero added to each end, but that would be a waste of > computation if you used the zero coefficients. > > Dirk Bell > DSP Consultant
Thanks Dirk. After a little bit of reading and experimenting, it appears to me that the MATLAB coefficients so generated for a Halfband filter were because of the fact that they were implemented as polyphase structure. The coefficients and the command use dto generate them are as follows: dhb = fdesign.decimator(2, 'halfband', 'N,AST', 20, 80, 200e6); hb = design(dhb); hb.Numerator = 0 0.0015 0 -0.0083 0 0.0283 0 -0.0801 0 0.3087 0.5000 0.3087 0 -0.0801 0 0.0283 0 -0.0083 0 0.0015 0 Regards, vizziee.
On Jul 23, 11:55&#4294967295;am, vizziee <vizz...@gmail.com> wrote:
> On Jul 9, 12:47&#4294967295;pm, Dirk Bell <bellda2...@cox.net> wrote: > > > > > On Jul 8, 6:44&#4294967295;pm, vizziee <vizz...@gmail.com> wrote: > > > > > Check your equations. &#4294967295;I get > > > > > ( ( (22-1)/2 )/20 + ( (22-1)/2 )/10 + ( (1010-1)/2 )/5 ) = 102.4750 > > > > which is consistant with what you are actually getting, not what you > > > > are calculating. > > > > > Also note that the filters you are identifying as half-band filters > > > > are not actually half-band filters. &#4294967295;Half-band filters have the > > > > property that almost half of the coefficients are zero, saving > > > > calculations, which may be useful to you. But, among other properties, > > > > the lengths of halfband filters are constrained to {3, 7, 11, 15, 19, > > > > 23, 27, ..., previous+4, ...}, so a filter of length 22 isn't a half- > > > > band filter. > > > > > Dirk Bell > > > > Thanks Dirk. I checked the Halfband filters that I generated in > > > MATLAB. It says it has Direct Form Polyphase Filter structure. The > > > coefficients were generated by specifying 'halfband' option to > > > fdesign.decimator function. The number of generated coefficients for > > > this half-band decimator is actually 21 and I padded a zero to make it > > > 22 for a 2-path polyphase implementation. > > > > I did a reading for Half-band filters and what you say about the > > > HalfBand FIR filter coefficients is absolutely true: the number of > > > coefficients should be 3+4n for a non-negative integer n. However I > > > couldn't reconcile the MATLAB halfband filter generated above with > > > this definition. Are halfband decimators different than the Nyquist > > > half-band filters? Also the way you calculated the delay of half-band > > > filters appears very much true. However assuming this is the polyphase > > > implementation of half-band decimators, shouldn't delay be calculated > > > like a standard polyphase filter delay formula: ((No_of_taps-1)/2)/ > > > Decimation_Factor? > > > > Thanks again for your insightful replies earlier. I could drastically > > > reduce the no of taps in my current design while also bettering the > > > response. Though the questions as above still linger in my mind. > > > > Regards, > > > > vizziee. > > > Vizziee, > > > Would you post the coefficients (or preferably all MATLAB inputs and > > resulting output) from your halfband design. > > > BTW a halfband filter could have a length 21 if it is really a length > > 19 filter with a zero added to each end, but that would be a waste of > > computation if you used the zero coefficients. > > > Dirk Bell > > DSP Consultant > > Thanks Dirk. After a little bit of reading and experimenting, it > appears to me that the MATLAB coefficients so generated for a Halfband > filter were because of the fact that they were implemented as > polyphase structure. The coefficients and the command use dto generate > them are as follows: > > dhb = fdesign.decimator(2, 'halfband', 'N,AST', 20, 80, 200e6); > hb = design(dhb); > hb.Numerator = > 0 &#4294967295; &#4294967295;0.0015 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; -0.0083 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; &#4294967295;0.0283 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 > -0.0801 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; &#4294967295;0.3087 &#4294967295; &#4294967295;0.5000 &#4294967295; &#4294967295;0.3087 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 > -0.0801 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; &#4294967295;0.0283 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; &#4294967295;-0.0083 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 > 0.0015 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 > > Regards, > vizziee.
I gather that since I specified the order of this half-band filter, it is bound to have 21 coefficients. The condition N = 3q+1 where N = order of the filter and q a non-neg integer for half-band filters is only applicable when one designs it for "minimum order". Regards, vizziee.
On Jul 23, 6:25&#4294967295;pm, vizziee <vizz...@gmail.com> wrote:
> On Jul 23, 11:55&#4294967295;am, vizziee <vizz...@gmail.com> wrote: > > > > > > > On Jul 9, 12:47&#4294967295;pm, Dirk Bell <bellda2...@cox.net> wrote: > > > > On Jul 8, 6:44&#4294967295;pm, vizziee <vizz...@gmail.com> wrote: > > > > > > Check your equations. &#4294967295;I get > > > > > > ( ( (22-1)/2 )/20 + ( (22-1)/2 )/10 + ( (1010-1)/2 )/5 ) = 102.4750 > > > > > which is consistant with what you are actually getting, not what you > > > > > are calculating. > > > > > > Also note that the filters you are identifying as half-band filters > > > > > are not actually half-band filters. &#4294967295;Half-band filters have the > > > > > property that almost half of the coefficients are zero, saving > > > > > calculations, which may be useful to you. But, among other properties, > > > > > the lengths of halfband filters are constrained to {3, 7, 11, 15, 19, > > > > > 23, 27, ..., previous+4, ...}, so a filter of length 22 isn't a half- > > > > > band filter. > > > > > > Dirk Bell > > > > > Thanks Dirk. I checked the Halfband filters that I generated in > > > > MATLAB. It says it has Direct Form Polyphase Filter structure. The > > > > coefficients were generated by specifying 'halfband' option to > > > > fdesign.decimator function. The number of generated coefficients for > > > > this half-band decimator is actually 21 and I padded a zero to make it > > > > 22 for a 2-path polyphase implementation. > > > > > I did a reading for Half-band filters and what you say about the > > > > HalfBand FIR filter coefficients is absolutely true: the number of > > > > coefficients should be 3+4n for a non-negative integer n. However I > > > > couldn't reconcile the MATLAB halfband filter generated above with > > > > this definition. Are halfband decimators different than the Nyquist > > > > half-band filters? Also the way you calculated the delay of half-band > > > > filters appears very much true. However assuming this is the polyphase > > > > implementation of half-band decimators, shouldn't delay be calculated > > > > like a standard polyphase filter delay formula: ((No_of_taps-1)/2)/ > > > > Decimation_Factor? > > > > > Thanks again for your insightful replies earlier. I could drastically > > > > reduce the no of taps in my current design while also bettering the > > > > response. Though the questions as above still linger in my mind. > > > > > Regards, > > > > > vizziee. > > > > Vizziee, > > > > Would you post the coefficients (or preferably all MATLAB inputs and > > > resulting output) from your halfband design. > > > > BTW a halfband filter could have a length 21 if it is really a length > > > 19 filter with a zero added to each end, but that would be a waste of > > > computation if you used the zero coefficients. > > > > Dirk Bell > > > DSP Consultant > > > Thanks Dirk. After a little bit of reading and experimenting, it > > appears to me that the MATLAB coefficients so generated for a Halfband > > filter were because of the fact that they were implemented as > > polyphase structure. The coefficients and the command use dto generate > > them are as follows: > > > dhb = fdesign.decimator(2, 'halfband', 'N,AST', 20, 80, 200e6); > > hb = design(dhb); > > hb.Numerator = > > 0 &#4294967295; &#4294967295;0.0015 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; -0.0083 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; &#4294967295;0.0283 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 > > -0.0801 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; &#4294967295;0.3087 &#4294967295; &#4294967295;0.5000 &#4294967295; &#4294967295;0.3087 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 > > -0.0801 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; &#4294967295;0.0283 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 &#4294967295; &#4294967295;-0.0083 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 > > 0.0015 &#4294967295; &#4294967295; &#4294967295; &#4294967295; 0 > > > Regards, > > vizziee. > > I gather that since I specified the order of this half-band filter, it > is bound to have 21 coefficients. The condition N = 3q+1 where N = > order of the filter and q a non-neg integer for half-band filters is > only applicable when one designs it for "minimum order". > > Regards, > > vizziee.- Hide quoted text - > > - Show quoted text -
Vizzee, You have a newer version of MATLAB than I do, so I do not know what all of the implications are of the MATLAB code you posted. nor exactly how you are going to use the result. Here are a couple of comments you can read and forget if they are not relevant to what you are doing. If you are using this as a polyphase filter implemented as two equal length filters then you would drop the leading 0 coefficient. When you then put alternate coefficients into the two filters, one will be all nonzero taps, and the other will be all zeros except for the 0.5 term. If you implement this using a generic decimate by two polyphase implementation then the second section will do a lot of multiplies by zero. This negates the main advantage of using a halfband filter, which is not multiplying by zero coefficients. So if you are interested in multiplier efficiency, a general purpose polyphase filter implementation should not be used for a decimating halfband filter. There might be a more efficient implementation script in the newer MATLAB or you could write your own. Dirk Bell DSP Consultant