filt-filt function Error: First denominator filter coefficient must be non-zero.

20 ビュー (過去 30 日間)
Brittny Freeman
Brittny Freeman 2019 年 1 月 1 日
回答済み: Star Strider 2019 年 1 月 1 日
Hello all,
I've run into an error that I was hoping someone could help shed light on for me. I am trying to create a bandpass filter kernal using firls to apply with the filt filt command. My code is highlighted below:
PitchBL = detrend(PitchBL); %(Remove the mean from the signal)
Fs = 100; %(Sampling Freq, in Hz)
nyquist = Fs/2;
n = 255; %(Filter Order)
f = [0 0.5 0.75 1.75 2 nyquist]/nyquist; %(Filter Kernal Shape Vector)
a = [0 0 1 1 0 0]; %(Filter Attenuation Vector)
d = firls(n,f,a);%(Construct Filter Kernal)
fvtool(d,5,'OverlayedAnalysis','phase')
PitchBL = filtfilt(d,a,PitchBL);
In which the variable nyquist = Fs/2 = 100 Hz/, and where the variable PitchBL is my orginal 1-D time series data vector that I am applying the bandpass filter on. I would like the upper transition region to run from 0.5 Hz - 0.75 Hz, I would like to run the pass band frequency region from 0.75 Hz - 1.75 Hz, and lower transition region from 1.75 Hz - 2 Hz.
Unfortunalely, I keep running into the following error, that I do not understand how to solve:
Error using filter
First denominator filter coefficient must be non-zero.
Error in filtfilt>ffOneChan (line 261)
[~,zo] = filter(b(:,ii),a(:,ii), xt, zi(:,ii)*xt(1)); % yc1 not needed
Error in filtfilt (line 104)
y = ffOneChan(b,a,x,zi,nfact,L);
I have attached a copy of the PitchBL time series data vertor in case its needed. Thanks in advance for your help.

回答 (1 件)

Star Strider
Star Strider 2019 年 1 月 1 日
I’m not entirely certain what you want to do. However assigning ‘1’ to the numerator usually works for FIR filters.
Try this to see how your filter works:
Fs = 100; %(Sampling Freq, in Hz)
nyquist = Fs/2;
n = 255; %(Filter Order)
f = [0 0.5 0.75 1.75 2 nyquist]/nyquist; %(Filter Shape Vector, [0,0.5)
a = [0 0 1 1 0 0]; %(Filter Attenuation Vector)
d = firls(n,f,a);%(Construct Filter Kernal)
figure
freqz(d, 1, 2^16, Fs)
You obviously know what you’re doing with respect to filter design, so I’m certain you can take it from there!

カテゴリ

Help Center および File ExchangeDigital Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by