BUTTER function returning slightly different results for Signal Processing Toolbox in R2020b and R2021a on same computer (Win10)
6 ビュー (過去 30 日間)
古いコメントを表示
[numerator, denominator] = butter(9, 0.5 / (100/2), 'high')
The returned numerator coefficients are slightly different for R2021a when compared to output from R2020b on the same Win10 computer. The difference is quite small (on the order of 1E-13) but is resulting in some analysis differences. I get identical coefficient values for R2020b, R2020a or R2019a.
I tried using a technique outlined in an older thread where user appeared to run into a similar issue but differences persist ( https://www.mathworks.com/matlabcentral/answers/98640-why-does-the-butter-function-return-different-results-for-signal-processing-toolbox-4-3-and-5-0 ).
Matlab release notes don't indicate something was changed in BUTTER function for R2021a version.
回答 (1 件)
Jan
2022 年 1 月 11 日
編集済み: Jan
2022 年 1 月 11 日
You can compare both results with this cheap implementation of a high pass Butterworth filter:
format long g
[num, den] = butter(9, 0.5 / (100/2), 'high');
[num2, den2] = cheapButterHigh(9, 0.5 / (100/2));
[num.' - num2.' , den.' - den2.']
function [num, den] = cheapButterHigh(n, W)
% A simple high pass Butterworth implementation.
% Jan, Heidelberg, CC BY-SA 3.0
V = tan(W * 1.5707963267948966); % pi/2
Q = exp((1.5707963267948966i / n) * ((2 + n - 1):2:(3 * n - 1)));
Sg = 1 ./ prod(-Q);
Sp = V ./ Q;
% Bilinear transform:
P = (1 + Sp) ./ (1 - Sp);
G = real(Sg / prod(1 - Sp));
Z = ones(length(Q), 1);
% From Zeros, Poles and Gain to B (numerator) and A (denominator):
num = G * real(poly(Z));
den = real(poly(P));
end
For large n this implementation is assumed to be less stable than Matlab's version, but I need it for n < 12 only.
Although this cheaper version is 10 times faster, it is not thought to save run time: Usually a program does not need tenthousands of different filter parameters.
2 件のコメント
Chris Heyman
2023 年 5 月 10 日
Hi JS,
Did you ever recieve a response from Matlab about this?
Thanks
-C
参考
カテゴリ
Help Center および File Exchange で Filter Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!