help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why does fir2 do such strange thing for odd filter order (even number of


From: Lev Serebryakov
Subject: Why does fir2 do such strange thing for odd filter order (even number of taps)?
Date: Wed, 12 Nov 2014 14:05:52 +0300
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512


 I'm trying to understand implementation of fir2 function from package
"signal". It has one strange place: ifft() call itself. Now it looks like

## Transform frequency response into time response and
## center the response about n/2, truncating the excess
if (rem(n,2) == 0)
 b = ifft([grid ; grid(grid_n:-1:2)]);
 mid = (n+1)/2;
 b = real ([ b([end-floor(mid)+1:end]) ; b(1:ceil(mid)) ]);
else
 ## Add zeros to interpolate by 2, then pick the odd values below.
 b = ifft([grid ; zeros(grid_n*2,1) ;grid(grid_n:-1:2)]);
 b = 2 * real([ b([end-n+1:2:end]) ; b(2:2:(n+1))]);
endif

 And I don't understand "Add zeros to interpolate by 2, then pick the
odd values below." part. Why does it do this
interpolate-and-take-odd-values? Why it is required only for even
number of taps? Why does it takes odd values? Is it critical, or even
ones will work too?

 I've read several textbooks, articles and tutorials about FFT-based
FIR designing, and no one mention special processing for even number
of taps (odd order). Every source I read is in agreement with method,
which is used for even order — mirror specter, take ifft(), rotate. It
is clear. And second branch is complete mistery for me.

 I've found this old post

http://octave.1599824.n4.nabble.com/fir1-bug-for-odd-orders-td4642204.html

 But it doesn't explain anything to me, as I don't know which "the
long standing bug about fir1" it refers to, and could not find this
bug in current bugtracker (yes, it is very old post in discontinued
mailing list).

 Could somebody explain this "magic" to me or point to some
explanation on Internet?

 Thank you.

- -- 
// Black Lion AKA Lev Serebryakov
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)

iQJ8BAEBCgBmBQJUYz8QXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRGOTZEMUNBMEI1RjQzMThCNjc0QjMzMEFF
QUIwM0M1OEJGREM0NzhGAAoJEOqwPFi/3EePsPwQAJwBcDSexg7Ju3u3J//tzadH
3x+E9GDAWD3UaPB1Z2xW1FF1/yhE1W+OU061P9sr3YusywwpKhwRGjooFXxGW3kS
cMtZr7VBdLxnJQmaU/o8OiwDgbP6Bjqs8vobjrclnsYk1Lnm3od06x/xz5vKxZhN
VWNOA6f9Gazg5NeeaAlL8mXUx9oWPBuH0k9qnLbRUDuCldypDL2/IbR+AO/kcQeC
+hw2oLlDX184ZD4jmUKhKBaCghQC71xRgP8KsObQAAIx01N6ItfGAb+Di47yEbZS
lwkJuLlPV5M0VkuprStmOFTddMb8R8utvXVWpLKvn4vXmolDdtZISsZZVlD5qAg1
8CGHWlY3BejSZ090hSbA3DGJ72fGz57xRfq3lb+qBOmSV1szOeXTuqo8xuKgEtF2
fjanINl6LVDTIdsRROKdz/w89BiOxdaXCFdCwX+0EJeaMBC/2tZ/xcRg5EikFjti
PfmEznLeG1znDDAQrnRJztuXdpnMUuREHhgfQq+XiHb9xgrYFnE4JAE0erjNPxW9
z3TGnDNV/gvu+AR9OGUsLDOpwS40WTmpZXCnwd7P6bMPlh4JfmR1B6xBNBerT0iK
yeDLH7f+jBDYKCS3Om1jalTnC8+WSXWGSyhEnrbymMzwVOucLWMJQGBipQOPqLYu
GAh+1vjuWsWfIH7w/9ax
=EOu2
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]