# Question on filter implementation ... Classic List Threaded 6 messages Open this post in threaded view
|

## Question on filter implementation ...

 Dear listmembers, I am currently experimenting with the signal - package using i. e. butter() and cheby1() functions. If I do a [b a]=butter(2,0.0208333); [H W]=freqz(b,a,48000); sig=20*log10(abs(H)); semilogx(sig) I get a nice and clean plot. Looks as expected. Same behavior when using cheby1 .... However, if I replace [b a]=butter(2,0.0208333); by [b a]=butter(10,0.0208333); the resulting graph is a mess. Enlarging the degree of the filter beyond 8 leads to very jumpy, noisy graphs. When I do the same in Matlab no such issues show. I found of the coefficients to become very small with that high filter degree. Any hints how to improve this besides not designing so steep filters? Is there an option to increase the internal resolution? Thank you for any feedback, best regards Dieter Jurzizta -- ----------------------------------------------------------- Dr.-Ing. Dieter Jurzitza                    76131 Karlsruhe
Open this post in threaded view
|

## Re: Question on filter implementation ...

 On Thu, Jan 30, 2020 at 2:41 PM Dr.-Ing. Dieter Jurzitza <[hidden email]> wrote:Dear listmembers, I am currently experimenting with the signal - package using i. e. butter() and cheby1() functions. If I do a [b a]=butter(2,0.0208333); [H W]=freqz(b,a,48000); sig=20*log10(abs(H)); semilogx(sig) I get a nice and clean plot. Looks as expected. Same behavior when using cheby1 .... However, if I replace [b a]=butter(2,0.0208333); by [b a]=butter(10,0.0208333); the resulting graph is a mess. Enlarging the degree of the filter beyond 8 leads to very jumpy, noisy graphs. When I do the same in Matlab no such issues show. I found of the coefficients to become very small with that high filter degree. Any hints how to improve this besides not designing so steep filters? Is there an option to increase the internal resolution? Thank you for any feedback, best regards Dieter Jurzizta -- ----------------------------------------------------------- Dr.-Ing. Dieter Jurzitza                    76131 Karlsruhe Deiter: this is a known limitation, and yes we need more resolution.@Mike Do you think we could use the symbolic pkg. and VPA to calculate these higher order coefficients? -- DAS Open this post in threaded view
|

## Re: Question on filter implementation ...

 On 30/01/2020 22:32, Doug Stewart wrote: On Thu, Jan 30, 2020 at 2:41 PM Dr.-Ing. Dieter Jurzitza <[hidden email]> wrote: Dear listmembers, I am currently experimenting with the signal - package using i. e. butter() and cheby1() functions. If I do a [b a]=butter(2,0.0208333); [H W]=freqz(b,a,48000); sig=20*log10(abs(H)); semilogx(sig) I get a nice and clean plot. Looks as expected. Same behavior when using cheby1 .... However, if I replace [b a]=butter(2,0.0208333); by [b a]=butter(10,0.0208333); the resulting graph is a mess. Enlarging the degree of the filter beyond 8 leads to very jumpy, noisy graphs. When I do the same in Matlab no such issues show. I found of the coefficients to become very small with that high filter degree. Any hints how to improve this besides not designing so steep filters? Is there an option to increase the internal resolution? Thank you for any feedback, best regards Dieter Jurzizta -- ----------------------------------------------------------- Dr.-Ing. Dieter Jurzitza                    76131 Karlsruhe Deiter: this is a known limitation, and yes we need more resolution. @Mike  Do you think we could use the symbolic pkg. and VPA to calculate these higher order coefficients?  -- DAS When you produce frequency plot, use pole-zero implementation instead of polynomial. I use the following code: function freq_response = eval_filter_through_zpg(zeros_vector, poles_vector, gain_scalar, zfrequency_range)   numerator = ones(1, length(zfrequency_range));   for zero_number = 1:length(zeros_vector)     numerator = numerator .* (zfrequency_range - zeros_vector(zero_number));   endfor   denominator = ones(1, length(zfrequency_range));   for pole_number = 1:length(poles_vector)     denominator = denominator .* (zfrequency_range - poles_vector(pole_number));   endfor   freq_response = gain_scalar * numerator ./ denominator; endfunction ... [bfzeros, bfpoles, bfgain] = butter(zorder, lower_zcutoff); ... two_pi = 2 * pi; relative_all_freqs = (0:half_number_of_points_in_fft) / number_of_points_in_fft; relative_omegas = two_pi * relative_all_freqs; relative_iomegas = i * relative_omegas; exp_of_relative_iomegas = exp(relative_iomegas); ... freq_response = \     eval_filter_through_zpg\       (       bfzeros, # zeros_vector,       bfpoles, # poles_vector,       bfgain,            # gain_scalar,       exp_of_relative_iomegas # zfrequency_range       ); --Sergei.
Open this post in threaded view
|

## Re: Question on filter implementation ...

 In reply to this post by Doug Stewart-4 On Thu, Jan 30, 2020 at 15:32:37 -0500, Doug Stewart wrote: > Deiter: this is a known limitation, and yes we need more resolution. > > @Mike >  Do you think we could use the symbolic pkg. and VPA to calculate these > higher order coefficients? You could certainly try. But as Sergei noted, the best approach is to always use the pole-zero representation when working with IIR filters. Cheers, -- mike signature.asc (849 bytes) Download Attachment
 On 30/01/2020 23:03, Mike Miller wrote: ```On Thu, Jan 30, 2020 at 15:32:37 -0500, Doug Stewart wrote: ``` ```Deiter: this is a known limitation, and yes we need more resolution. @Mike Do you think we could use the symbolic pkg. and VPA to calculate these higher order coefficients? ``` ```You could certainly try. But as Sergei noted, the best approach is to always use the pole-zero representation when working with IIR filters. Cheers, ``` For the gory details one may visit http://bugzilla.scilab.org/show_bug.cgi?id=1635 . --Sergei.