How can I smooth this plot?
이전 댓글 표시
So i have a large data set. I just copied here one set, as an example. I tried to use filters to get rid of those small spikes, but i ended up with just a completely straight line.
I split this data in thre sectoins (720 length each) , because I want to kee that stepping characteristic of it.
I am using R2017b edition of matlab, so there are many functions i cannot use to do this.
Could anyone help me with this?
채택된 답변
추가 답변 (1개)
Hank
2019년 11월 13일
A little more crudely than Strider's answer, since you may not have some of those functions in R2017...
Here is a function that cuts a function up at significant discontinuites and smooths the individual parts. If you don't have the smooth function, replace it with a simple one from the file exchange like https://www.mathworks.com/matlabcentral/fileexchange/19998-fast-smoothing-function
function xs = smoothsmallstuff(x,w)
sig = 6;
x = x(:);
dx = diff(x);
mdx = mean(dx);
sdx = std(dx);
idiscont = [1; find(abs(dx-mdx)/sdx>6); length(x)];
xs = x;
for i = 1:length(idiscont)-1
sect = idiscont(i):idiscont(i+1);
xs(sect) = smooth(x(sect),w);
end
end
댓글 수: 2
Lala0099
2019년 11월 14일
Hank
2019년 11월 14일
Did you include the, smoothing width when you used the function?
smooth(x,width) % width = index-width of moving average. Default is 5 points
The default smoothing width is only 5 points. Since your data is really large >1000 points, 5pt smoothing appear effective. Try:
smooth(x,300)
Note this will also smooth out larg discontinuities, hence the function i wrote above.
카테고리
도움말 센터 및 File Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
