Suggestions for filtering a signal
Show older comments
Hello, I have a signal as shown here signal and I need to filter it so that the resultant will only have the noiseless pulse signal.I have used the SG filter as sgolayfilt(b,3,31); adn the response is shown in the link image. The smoothed from SGfilter still needs to be filtered as the required is only the pure pulse signal.So tried using the LP filter as
d = fdesign.lowpass('Fp,Fst,Ap,Ast',3,5,0.5,40,100);
Hd = design(d,'equiripple');
output = filter(Hd,SGfiltereoutput);
But the resultant shown in the 3rd plot of the link image is very different to the one expected. Can anyone suggest how to get a pure pulse signal from the signal shown in the 1 part of link image. thanks.
2 Comments
Wayne King
on 27 Nov 2013
Please attach the data
Gova ReDDy
on 27 Nov 2013
Edited: Gova ReDDy
on 27 Nov 2013
Answers (1)
Image Analyst
on 27 Nov 2013
0 votes
Well you obviously filtered it too much. I think the Savitzky-Golay filter is still the way to go. Why don't you just increase the window width to get more smoothing? But if you're looking to recover a pure delta function or step function, you're not going to do it by smoothing the signal - that's the exact opposite of what you want to do. I'm not sure how you define pulse. Can you give an example of the pure pulse or signal that you're trying to get?
20 Comments
Gova ReDDy
on 27 Nov 2013
Edited: Image Analyst
on 27 Nov 2013
Image Analyst
on 27 Nov 2013
Link doesn't work. You can filter something to the max extent possible. You can even get a perfectly flat, constant value if you want to take it that far. There are tons of denoising methods. Are you not able to do what you need to do if you just use something simple like median filter or a box averaging filter? What IS it that you want to do if you had a perfectly noise-free signal?
Gova ReDDy
on 27 Nov 2013
Edited: Gova ReDDy
on 27 Nov 2013
Image Analyst
on 27 Nov 2013
Looks like you pretty much already got something very close to that. What's wrong with it? Can you not determine what you need to determine? Can you answer my question from above: What IS it that you want to do if you had a perfectly noise-free signal?
Gova ReDDy
on 27 Nov 2013
Image Analyst
on 27 Nov 2013
If you have the Signal Processing Toolbox, you can use findpeaks() without even doing any smoothing. Just give it a threshold of 0.1 or something. Otherwise you can increase the window size of the Savitzky-Golay filter to get the red line if you want, though it's not necessary if you just want to count peaks. Do you have a longer signal that has 3 or 4 or more peaks in it?
Gova ReDDy
on 28 Nov 2013
Gova ReDDy
on 28 Nov 2013
Image Analyst
on 28 Nov 2013
Probably the SG or median filter. Try them and see if they let you measure what you need to measure.
Gova ReDDy
on 29 Nov 2013
Image Analyst
on 29 Nov 2013
See my demo, attached below in blue.
Gova ReDDy
on 2 Dec 2013
Image Analyst
on 2 Dec 2013
Your link is broken.
Gova ReDDy
on 2 Dec 2013
Edited: Gova ReDDy
on 2 Dec 2013
Image Analyst
on 3 Dec 2013
That zooms in on some very specialized areas. I suggest you first find the tall peaks, and the second tallest peaks, then filter only the part in between.
Gova ReDDy
on 3 Dec 2013
Edited: Gova ReDDy
on 3 Dec 2013
Image Analyst
on 3 Dec 2013
Once you have the highest peaks, you just have to fall down the right side and then go back up until you hit another peak. Then you create a binary vector with the location of the "in between" parts. Then filter the whole signal but assign the smoothed elements only in the location of the binary vector.
filteredSignal(binaryVector) = smoothedSignal(binaryVector);
Gova ReDDy
on 3 Dec 2013
Edited: Gova ReDDy
on 3 Dec 2013
Image Analyst
on 3 Dec 2013
It's just MATLAB code. And not even as hard as what's inside sgolay(). Can't you use the Coder to create C code to put onto your microcontroller?
Gova ReDDy
on 3 Dec 2013
Edited: Gova ReDDy
on 4 Dec 2013
Categories
Find more on Signal Generation, Analysis, and Preprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!