![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175362/image.png)
Need help in understanding the bandstop filter output
1 view (last 30 days)
Show older comments
Hello,
I want to fitler the frequency components coefficients of particualr range in a signal for which I have used the bandstop filter function here as shown below
subplot(2,1,1),plot(data,'-r');
filtered1 = bandstop_butterworth(data,[.2 .35],100,3);
finalsignal = bandstop_butterworth(filtered1,[.5 4],100,3);
subplot(2,1,2),plot(finalsignal,'-r');
I don't understand why the filter response(shown in the attached m-figure) is something like the sinusoidal which is similar to input signal. I want to filter frequency in these range 1)0.2 to 0.35 2)0.5 to 4Hz
Can someone explain me about the filter output.
Thanks.
0 Comments
Answers (2)
Star Strider
on 7 Aug 2014
Edited: Star Strider
on 7 Aug 2014
I got the x and y data from your ‘.fig’ file in subplot(2,1,1). The Nyquist frequency of your signal is 0.5 Hz, so your second filter with a stopband of [0.5 4] will have no effect.
The fft of the data in the top subplot has essentially no signal energy in the stopband of your [0.2 0.35] filter:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175362/image.png)
What do you want to filter out of your signal?
3 Comments
Star Strider
on 7 Aug 2014
Edited: Star Strider
on 7 Aug 2014
You didn’t specify your sampling frequency in your original post, so I assumed the time vector in your ‘.fig’ file was the time vector that represented your signal sampling times.
I didn’t look in the File Exchange function to see what it did and how it designed its filters, so I don’t know what filters it designed. I had a difficult time designing Butterworth filters to your specifications, and even using the second-order-section implementation to avoid filter instability, it was difficult to get them to work. I finally defaulted to Chebyshev Type II filters, the design and implementation of which I include here:
Fs = 100;
Fn = Fs/2;
% Design First Filter:
Ws1 = [0.2 0.35]/Fn;
n1 = 2; % Filter ORder
R = 20; % Stopband Attenuation
[b1, a1] = cheby2(n1,R,Ws1,'stop'); % Create Filter
[sos1,g1] = tf2sos(b1,a1); % SOS Implementation
figure(5)
freqz(sos1,1001) % Plot Normalised Response
% Design Second Filter:
Ws2 = [0.5 4.0]/Fn;
n2 = 2;
[b2, a2] = cheby2(n2,R,Ws2,'stop');
[sos2,g2] = tf2sos(b2,a2);
figure(6)
freqz(sos2,1001)
% Do Serial Filter Cascade:
YF1 = filtfilt(sos1,g1,YD); % ‘YD’ Is Your Signal in ‘subplot(2,1,1)’
YF2 = filtfilt(sos2,g2,YF1); % Output of Cascaded Filters
The filter responses in the freqz plots look correct to me. I notice that they eliminate most of your actual data, leaving you with essentially a baseline.
I can’t understand what you want to do on the basis of these data and your filter specifications. If you want to discuss that, perhaps we can get the information you want from your data.
Star Strider
on 7 Aug 2014
The paper is not the most forthcoming in its details. I have no experience with LMS or other types of adaptive filters — I never needed them and they never were part of my coursework — so I can’t help you with their implementation. I have worked with inexpensive, commercially-available fingertip pulse-oximeters that were more than adequate for my needs, and I successfully filtered out motion (and high-frequency) artifacts with a bandpass filter going from 0.05 Hz to 20 or 100 Hz, depending on what I was doing. I was primarily interested in the waveform (looking at arterial compliance), and the pulse-oximeter internal software gave me all of the rate and SO2 information I needed, as well as the waveform. Much of what the paper filters out — respiratory variation and such — are physiologically important, and I wanted to retain that information rather than discard it. (I would not suggest discarding it, but then I don’t know what you’re studying so you may have requirements I didn’t.)
4 Comments
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!