필터 지우기
필터 지우기

High-pass Butterworth filter and filtfilt

조회 수: 8 (최근 30일)
Guglielmo Giambartolomei
Guglielmo Giambartolomei 2017년 2월 15일
댓글: Star Strider 2017년 2월 16일
Hello everyone, I'm trying to high-filter a signal beacause when I perform a fft of the original signal I find a contribution at very low frequency even if I take the fft of detrend(signal). I want to cut out that contribution. I wrote this simple script:
Fcp=3; %cutoff frequency
[z,p,k]=butter(8,Fcp/(Fsp/2),'high');
sos=zp2sos(z,p,k);
%fvtool(sos,'Analysis','freq')
x101filtfilt=filtfilt(z,p,x101);
figure;
plot(t101,x101,t101,x101filtfilt);
grid on
title('PE101 (pressure signal)')
xlabel('t (s)')
ylabel('Pressure (kPa)')
legend({'Original PE101 Signal','Actual PE101 Signal (filtered and realigned signal)'});
The sampling frequency is 600 Hz and the signal x101 is about 180 s long. I receive the error: "Warning: Imaginary parts of complex X and/or Y arguments ignored". As a matter of fact the new signal x101filtfilt contains imaginary numbers. Where am I wrong? Thank you very much.
  댓글 수: 1
Jan
Jan 2017년 2월 15일
And does x101, z or p contain complex values? Which command produces this error?

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

채택된 답변

Star Strider
Star Strider 2017년 2월 15일
You have two errors that I can see.
1. You need both outputs from zp2sos:
[sos,g] = zp2sos(z,p,k);
2. Then use those in your filtfilt call:
x101filtfilt = filtfilt(sos,g,x101);
That should solve your imaginary number problem (unless ‘x101’ is complex).
I also analysed your filter with freqz:
freqz(sos, 2^16, Fsp)
It appears stable and that it will do what you want it to do.
  댓글 수: 2
Guglielmo Giambartolomei
Guglielmo Giambartolomei 2017년 2월 16일
Star Strider, you're a fallen angel; it works now! Your syntax is different from the one recommended in matlab guide. Thank you very much!
Star Strider
Star Strider 2017년 2월 16일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by