From: Bayo on 2 Mar 2010 11:05 Hi there, The code below shows my attempt at designing an elliptic IIR bandpass filter which is meant to process a real time signal. it is a concatenation of a low pass and a high pass filter. The problem is the output signal from the filter tends to "tail off" towards the end of the signal. From my research so far, it has been mentioned that this tailing off is due to "boundary condition" for the filter. Can anyone shed some light on this issue and how I can go about fixing it? My intention is to be able to change the cut-off frequency of this filter to achieve any filter frequency band I require (particularly narrowband filters for EEG signal processing) please help! -------------------------------------------------------------------------------------------------------------------- %Function: Design elliptic high pass and low pass filter using %ellipord to generate the lowest no of filter order function [LPf_eegData, HPf_eegData, BPf_eegData]=BPellipord(eegData) %% Design LowPass Filter (17Hz) Fs = 256; Rp=0.1; Rs=60; Wp = 15.8/(Fs/2); Ws = 17/(Fs/2); [n,Wp] = ellipord(Wp,Ws,Rp,Rs); %Generate minimum filter order for specs [z,p,k] = ellip(n,Rp,Rs,Wp); [sos,g] = zp2sos(z,p,k); %Convert to SOS form Hd = dfilt.df2tsos(sos,g); %Create a dfilt object %% Design Highpass filter (6 Hz) Wn = 5.8/(Fs/2); Wm = 6/(Fs/2); %rising edge from 5 to 6 [n,Wm] = ellipord(Wn,Wm,Rp,Rs); %Generate minimum filter order for specs [z,p,k] = ellip(n,Rp,Rs,Wm,'high'); [sos,g] = zp2sos(z,p,k); %Convert to SOS form Hp = dfilt.df2tsos(sos,g); %Create a dfilt fvtool(Hp,Hd); %% Apply filter [b,a] = sos2tf(Hd.sosMatrix,Hd.Scalevalues); [d,c] = sos2tf(Hp.sosMatrix,Hp.Scalevalues); HPf_eegData = filtfilt(d,c,eegData); LPf_eegData = filtfilt(b,a,eegData); BPf_eegData = filtfilt(b,a,HPf_eegData); ----------------------------------------------------------------------------------------------------------------------- Bayo
|
Pages: 1 Prev: Gui Next: Closed-loop optimal control problems with the level set toolbo |