Butterworth lowpass filtering without signal processing toolbox

조회 수: 32 (최근 30일)
John
John 2014년 6월 26일
답변: Fiza 2020년 9월 8일
Hi,
I'm trying to accomplish butterworth lowpass filtering but do not have the signal processing toolbox. Is it possible to do this type of filtering without this toolbox?

답변 (3개)

Jan
Jan 2014년 6월 26일
편집: Jan 2014년 7월 7일
This is a fair method to determine the coefficients for a Butterworth filter:
function [Z, P, G] = myButter(n, W, pass)
% Digital Butterworth filter, either 2 or 3 outputs
% Jan Simon, 2014, BSD licence
% See docs of BUTTER for input and output
% Fast hack with limited accuracy: Handle with care!
% Until n=15 the relative difference to Matlab's BUTTER is < 100*eps
V = tan(W * 1.5707963267948966);
Q = exp((1.5707963267948966i / n) * ((2 + n - 1):2:(3 * n - 1)));
nQ = length(Q);
switch lower(pass)
case 'stop'
Sg = 1 / prod(-Q);
c = -V(1) * V(2);
b = (V(2) - V(1)) * 0.5 ./ Q;
d = sqrt(b .* b + c);
Sp = [b + d, b - d];
Sz = sqrt(c) * (-1) .^ (0:2 * nQ - 1);
case 'bandpass'
Sg = (V(2) - V(1)) ^ nQ;
b = (V(2) - V(1)) * 0.5 * Q;
d = sqrt(b .* b - V(1) * V(2));
Sp = [b + d, b - d];
Sz = zeros(1, nQ);
case 'high'
Sg = 1 ./ prod(-Q);
Sp = V ./ Q;
Sz = zeros(1, nQ);
case 'low'
Sg = V ^ nQ;
Sp = V * Q;
Sz = [];
otherwise
error('user:myButter:badFilter', 'Unknown filter type: %s', pass)
end
% Bilinear transform:
P = (1 + Sp) ./ (1 - Sp);
Z = repmat(-1, size(P));
if isempty(Sz)
G = real(Sg / prod(1 - Sp));
else
G = real(Sg * prod(1 - Sz) / prod(1 - Sp));
Z(1:length(Sz)) = (1 + Sz) ./ (1 - Sz);
end
% From Zeros, Poles and Gain to B (numerator) and A (denominator):
if nargout == 2
Z = G * real(poly(Z'));
P = real(poly(P));
end
  댓글 수: 2
erico vale
erico vale 2018년 6월 20일
Could you comment the code ?
Eduardo Rey
Eduardo Rey 2020년 3월 14일
Jan, I tried using this code to get coefficents for a low-pass response using n=1, w = 0.04 since fs=2K and fc = 40Hz but it gave me -1. Am I doing something wrong?

댓글을 달려면 로그인하십시오.


Anastasios
Anastasios 2014년 6월 26일
Hi John,
You can download a 30-day free trial if you want to do something for now
https://www.mathworks.com/programs/trials/trial_request.html?prodcode=SG&eventid=616177282&s_iid=main_trial_SG_cta2
Tasos
  댓글 수: 2
John
John 2014년 6월 26일
That's not an option for now, and that decision doesn't come from me. Is there another option you can think of?
Anastasios
Anastasios 2014년 6월 26일
Check the following webpage at Rice University. Hopefully you can find your answer there. 2D Frequency Domain Filtering and the 2D DFT

댓글을 달려면 로그인하십시오.


Fiza
Fiza 2020년 9월 8일
Hi,
Under what license can i use this code?

카테고리

Help CenterFile Exchange에서 Analog Filters에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by