
From:  Sergei Steshenko 
Subject:  Re: Question on filter implementation ... 
Date:  Thu, 30 Jan 2020 22:45:25 +0200 
Useragent:  Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 
On Thu, Jan 30, 2020 at 2:41 PM Dr.Ing. Dieter Jurzitza <address@hidden> 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.
@MikeDo you think we could use the symbolic pkg. and VPA to calculate these higher order coefficients?

DAS
When you produce frequency plot, use polezero 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.
[Prev in Thread]  Current Thread  [Next in Thread] 