How to smooth this plot?

7 views (last 30 days)
Dimitrios
Dimitrios on 7 Dec 2014
Commented: Image Analyst on 7 Dec 2014
I am ploting a signal in frequency domain and i am trying to smooth the results in order to be clear for the viewer.The following plot shows my results:
In red line the desired results.I am trying to use the smooth function but cant consider which method and span is the appropriate for these results.Any recomendations?
Edit:
I used sgolayfilt() with the following results,where it can e seen that it cannot catch the high values:
Is there a way to 'say to the function that i want to smooth my results in respect to my high values?I attach in a file the signal.

Accepted Answer

Image Analyst
Image Analyst on 7 Dec 2014
If you have the Signal Processing Toolbox, try sgolayfilt() to do a moving polynomial window. If you have the Curve Fitting Toolbox, try lowess(), loess(), smooth(), or rloess(). Attach your data if you want an example with your data. I've attached an example for the Savitzky-Golay filter, which will produce this image.
  2 Comments
Dimitrios
Dimitrios on 7 Dec 2014
Thanks for your answer.I edited my question in case you want to check.
Image Analyst
Image Analyst on 7 Dec 2014
The high values get smoothed away because it's assumed they are outliers. You can add them back in if you want by replacing any elements where the original minus the smoothed is more than some amount, by the original. Do you want to do that? This will put certain spikes back in.
% Find the difference signal.
diffSignal = signal - smoothSignal;
% Find where the difference is more than 2.
bigSpikes = diffSignal > 2;
% Replace with original
smoothSignal(bigSpikes) = signal(bigSpikes);
You can use abs(diffSignal > 2) if you want to put back in big negative going spikes also.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!