![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177040/image.jpeg)
How to smooth this plot?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dimitrios
am 7 Dez. 2014
Kommentiert: Image Analyst
am 7 Dez. 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146358/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146359/image.png)
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.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 7 Dez. 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177040/image.jpeg)
Or you could try John's SLM app: http://www.mathworks.com/matlabcentral/fileexchange/24443-slm-shape-language-modeling
2 Kommentare
Image Analyst
am 7 Dez. 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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!