Smoothing 2 columns text file
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I would like to have a smoothed line fitting my data in order to get rid of the noise. Below is the what the data looks like along with the code I am using. How can I implement a simple smoothing method to my code? Thank you.
fid=fopen('1GPL.txt');
s=textscan(fid,'%d %d %d','headerlines',23);
fclose(fid);
x=s{1};
y=s{2};
xx=x(x>=400 & x<=700);
yy=y(x>=400 & x<=700);
plot(xx,yy)
Respuestas (1)
Jorrit Montijn
el 1 de Dic. de 2016
Hi Alex,
Have you looked into using a function like filtfilt()? You can look it up in the MATLAB help; you can use several built-in filters depending on the type of filtering you wish to apply.
Alternatively, you can perform a simple convolution with conv(). You could for example apply a Gaussian filter like this:
yyFiltered = conv(yy,normpdf(-2:2,0,1)./sum(normpdf(-2:2,0,1)),strFlag)
Note that this way you either get a shorter trace when strFlag is 'valid', or has artifacts near the edges, because of zero-padding when using strFlag = 'same'
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!