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!
