How can I smooth this plot?
Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (1)
Hank
el 13 de Nov. de 2019
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 comentarios
Lala0099
el 14 de Nov. de 2019
Hank
el 14 de Nov. de 2019
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.
Categorías
Más información sobre Smoothing and Denoising en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
