Right filter syntax for the [z,p,k] syntax

2 ビュー (過去 30 日間)
Peter
Peter 2013 年 6 月 27 日
Hi, I used the butterworth filter with the [b,a] syntax:
filtord=4;
SampleRate=20000;
d = fdesign.bandpass('N,F3dB1,F3dB2',4,100, 300,SampleRate);
hd = design(d,'butter');
% zero phase shift by reverse filtering
SignalFiltered=filtfilt(b,a, Signal);
Now I want to use higher order filter numbers where the help suggests to switch to the [z,p,k] syntax.
Wn=[100,300]/(SampleRate/2); % cutoff frequencies normalized by nyquist
ftype='bandpass';
filtord=10;
[z, p, k] = butter(filtord,Wn,ftype);
[sos,g]=zp2sos(z,p,k);
hd=dfilt.df2sos(sos,g);
Simple question: would will be the appropriate filter command (SignalFiltered=filtfilt(??))? Or is there a missing piece of code? Thanks for your advice!
P.S.: Is the missing code the following:
[b,a]= sos2tf(hd.sosMatrix,hd.ScaleValues);
SignalFiltered=filtfilt(b,a, Signal);
?????

採用された回答

Honglei Chen
Honglei Chen 2013 年 6 月 27 日
編集済み: Honglei Chen 2013 年 6 月 27 日
In general you don't want to switch back to b and a because you then have the numerical issue again.
If you have at least MATLAB R2011a, you can do
SignalFiltered = filtfilt(hd.sosMatrix,hd.ScaleValues,Signal);
Otherwise, you can do
hd.PersistentMemory = true;
y = filter(hd,Signal);
SignalFiltered = filter(hd,fliplr(y));
twice, one forward and one backward to mimic the behavior of filtfilt. You may need to set PersistentMemory to true to retain the state
  2 件のコメント
Peter
Peter 2013 年 6 月 28 日
Thanks for your assistance - unfortunately there ist still a phase shift (which I do not understand, because the filtfilt function is also based on the filter function). Nevertheless I found the filtfilthd.m file on the matlabe file exchange and it works pretty well.
SignalFiltered = filtfilthd(hd,Signal);
Honglei Chen
Honglei Chen 2013 年 6 月 28 日
filtfilt do something special to set the initial condition to reduce the transient, this is probably the reason you see some phase shift. Looks like filtfilthd duplicates that behavior.

サインインしてコメントする。

その他の回答 (1 件)

Peter
Peter 2013 年 6 月 27 日
Thanks for the advice. Could you give me a code snippet for the reverse filterung using filter (unfortunately I can't use the filtfilt function as mentioned above). Thanks a lot!
  1 件のコメント
Honglei Chen
Honglei Chen 2013 年 6 月 27 日
I updated the answer above

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by