필터 지우기
필터 지우기

How to apply bandpass filter

조회 수: 4 (최근 30일)
Elysi Cochin
Elysi Cochin 2017년 7월 22일
댓글: muhammad faiz 2017년 12월 4일
The attached signal file is of 20Hz sampling rate. Each row is a signal, i needed to to apply bandpass filter to each row and convert it in the frequency range 0.34 - 1 Hz.

채택된 답변

Star Strider
Star Strider 2017년 7월 22일
This filter will do what you want:
D = load('ehgSignal.mat');
s = D.val';
Fs = 20; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = [0.34 1.00]/Fn; % Passband Frequencies (Normalised)
Ws = [0.30 1.05]/Fn; % Stopband Frequencies (Normalised)
Rp = 10; % Passband Ripple (dB)
Rs = 50; % Stopband Ripple (dB)
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs); % Filter Order
[z,p,k] = cheby2(n,Rs,Ws); % Filter Design
[sosbp,gbp] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(1)
freqz(sosbp, 2^16, Fs) % Filter Bode Plot
tv = linspace(0, 1, length(s))/Fs; % Time Vector (s)
s_filt = filtfilt(sosbp,gbp, s); % Filter Signal
figure(2)
plot(tv, s_filt)
grid
NOTE The filtfilt function will operate on the first non-singleton dimension of ‘s’, so since ‘s’ is (12 x 35220), it is necessary to transpose it to filter along the rows ( columns in the transposed matrix).
  댓글 수: 3
Star Strider
Star Strider 2017년 7월 24일
Yes. The ‘s_filt’ variable are the filtered signals.
You can name the vectors whatever you want, of course.
muhammad faiz
muhammad faiz 2017년 12월 4일
sorry sir, i already try this code and it has some error on it, after i run this coding it say that "Reference to non-existent field 'val'." what does this mean ?

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

추가 답변 (1개)

muhammad faiz
muhammad faiz 2017년 12월 4일
excuse me sir, sorry for asking, i'm still new in using the matlab software. But i need to do a bandpass filter, which is i need to apply the band pass filter to the sound signal. right now i only knew how to play the audio file from the matlab and the file was in .wav format, how to get the .mat format from the file ? and how to apply the band pass filter coding sir ? i don't really understand about it. and what does the ehgsignal.mat mean ? i hope you can help me figure out this, thank you sir

카테고리

Help CenterFile Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by