Smoothing 2 columns text file
2 ビュー (過去 30 日間)
古いコメントを表示
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)
回答 (1 件)
Jorrit Montijn
2016 年 12 月 1 日
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'
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!