How to smooth this plot?

2 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2014-12-7
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 个评论
Dimitrios
Dimitrios 2014-12-7
Thanks for your answer.I edited my question in case you want to check.
Image Analyst
Image Analyst 2014-12-7
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.

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by