필터 지우기
필터 지우기

Applying Two Filters Simultaneously

조회 수: 10 (최근 30일)
Soeun Lee
Soeun Lee 2021년 7월 19일
댓글: Yazan 2021년 7월 20일
I'm trying to apply notch (stop) filter and highpass filter simultaneously for my data. Below is the code that I have so far.
Fs=24414;
t=0:1/Fs:435.13;
X=RawData;
Wn=10; % high cutoff
[b,a]=butter(5,Wn/Fs,"high");
Wn_2=[60 60]; % notch filter
y=filter(b,a,X);
[b,a]=butter(5,Wn_2/Fs,"stop");
z=filter(b,a,y);
plot(z);
What I'm trying to do is first apply highpass filter to my RawData (X) to obtain filtered data y, and then apply notch filter to y to obtain z.
Below is the graph that I'm getting. Please let me know what is wrong with my code. Thank you in advance for your help!
  댓글 수: 3
Soeun Lee
Soeun Lee 2021년 7월 20일
Here's the link to my data (the file itself is too large to upload) https://drive.google.com/file/d/1vmeak6nmDW5Z1v6IL0oVZc10I41K_thA/view?usp=sharing
Yazan
Yazan 2021년 7월 20일
Provide what frequencies you are trying to filter. Do you realize that the cutoff frequency of your butter filter is specified as 10/Fs, which is 3.3554e-08 the Nyquist rate (Fs/2)?

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

답변 (1개)

Chunru
Chunru 2021년 7월 20일
Fs=24414;
t=0:1/Fs:435.13;
X=rand(size(t))+2; % random noise + DC %RawData;
Wn=10; % high cutoff
[b,a]=butter(5,Wn/(Fs/2),"high");
% Filter response (Problem: very low cut off and very high Fs)
figure
freqz(b, a, 1024*64, Fs);
xlim([0 200]);
% DC will be filtered out by HPF
figure;
y=filter(b,a,X);
plot(y);
% Notch filter was not properly designed (againg Fs/F0 is very big)
% Wn_2=[60 60]; % notch filter
% [b,a]=butter(5,Wn_2/(Fs/2),"stop");
notchSpecs = fdesign.notch('N,F0,Q,Ap',6,60,10, 1, Fs);
notchFilt = design(notchSpecs,'SystemObject',false);
freqz(notchFilt, 1024*64, Fs);
Error using dfilt.basefilter/freqz (line 17)
This functionality is not available on remote platforms.
figure
z=filter(notchFilt,y);
plot(z);

카테고리

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