I have a signal and I filtered the signal using a cheby1 filter. the frequencies of the signal range from 0.058 to 349Hz. I had to remove frequencies above 0.7Hz. after filtering the signal again when I find the frequencies I'm getting frequencies above 0.7Hz.

 Accepted Answer

Star Strider
Star Strider on 9 Sep 2017

0 votes

I showed you how to correctly design a filter here. If you want to design a filter to remove all frequencies above 0.7 Hz, design a lowpass filter, specify the passband frequency as 0.7/Fn and the stopband at 0.72/Fn. Use a Chebyshev Type II filter for this, instead of a Type I, since you now want a relatively flat passband.

9 Comments

But when I'm using type 2 my filtered signal amplitude is very less. original signal amplitude - 25. filtered - 1*10^-3.
can't I use the cheby1 filter? Is my code wrong?
rohith bharadwaj
rohith bharadwaj on 10 Sep 2017
Edited: rohith bharadwaj on 10 Sep 2017
if my filter code is correct why I am getting frequencies again after filtering. [b,a] = cheby2(1,0.5,0.7/325,'low'); fil=filter(b,a,y);
I've with this. but again when I am finding the frequencies I am getting frequencies above 0.7Hz. Is there any reason for this?
Use the design approach I gave you. The second-order-section representation will produce a stable filter.
You haven’t stated your sampling frequency, and there is no time vector in your data file. From your code, I assume it is 650 Hz to produce a Nyauist frequency of 325 Hz.
yes, I've used your approach. My sampling frequency is 650Hz. My output is correct but my filtered signal gain is coming less than that of the original signal. How can I tune the gain or is there any approach to do so.
If you used this filter:
[b,a] = cheby2(1,0.5,0.7/325,'low');
fil=filter(b,a,y);
Your filter has one pole, and only has 0.5 dB stopband attenuation.
See if this one works better in your application:
Fs = 650
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = 0.7/Fn; % Passband Frequency (Normalised)
Ws = 0.72/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple (dB)
Rs = 50; % Stopband Ripple (dB)
[n,Ws] = cheb1ord(Wp,Ws,Rp,Rs); % Filter Order
[z,p,k] = cheby1(n,Rs,Ws,'low'); % Filter Design
[soslp,glp] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(5)
freqz(soslp, 2^16, Fs) % Filter Bode Plot
thank you :-)
My pleasure!
Wietse van Geel
Wietse van Geel on 3 Feb 2021
Edited: Wietse van Geel on 3 Feb 2021
EDIT: found your previous post in the link! I'll try that first
Thank you for this helpful post. I'm designing a filter for the first time, and find it quite challenging.
Could you clarify the above answer by explaining how the last part, ending with:
[soslp,glp] = zp2sos(z,p,k);
can be implemented as a filter?
This part works fine for me:
[b,a] = cheby2(1,0.5,0.7/325,'low');
fil=filter(b,a,y);
And playing around with the numbers and plotting the results give some idea of what happens.
Best,
Wietse
Wietse van Geel — My pleasure!
I have switched over to elliptic filters, since they are much more computationally efficient and generally perform much better. The code would now be:
Fs = 650
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = 0.7/Fn; % Passband Frequency (Normalised)
Ws = 0.72/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple (dB)
Rs = 50; % Stopband Ripple (dB)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Filter Order
[z,p,k] = ellip(n,Rp,Rs,Wp,'low'); % Filter Design
[soslp,glp] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(5)
freqz(soslp, 2^16, Fs) % Filter Bode Plot
Use the filtfilt function to do the actual filtering:
fil = filtfilt(soslp,glp,y); % Filter Signal
.

Sign in to comment.

More Answers (1)

kani mozhi
kani mozhi on 10 Sep 2018

0 votes

hi... i m wrk in bci data competition iii dataset 1.which filter have to use and please give the matlab code.. i m new in this area

Categories

Find more on Signal Processing Toolbox 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!