how to apply Sgolayfilter

2 次查看(过去 30 天)
maryam
maryam 2014-10-19
hi, i have a noisy signal with sampling frequency of 2*10^5 and nominal frequency of 50 hz. i want to apply sgolay filter to smooth the wave, if i choose frame size 4900, it takes to long for running the program. could you explain me how i should choose the filter order and frame size?thank you un advance

回答(2 个)

Image Analyst
Image Analyst 2014-10-19
That seems like an awfully wide window size. How long does it take? What is the order of the polynomial you are using? It shouldn't be more than 5 or so. Most of the time I use 2 or 3. You'll probably get garbage if you use orders like 20 or 30 or more. How many elements are in your signal? Sampling a 50 Hz signal 200,000 times per second seems unnecessarily rapid unless you are really trying to investigate the noise itself rather than just wanting a smoothed signal. Unless the signal is extraordinarily noisy, you should be able to get by with a signal around 11 - 41 elements I would think. You can post your data file and m-file if you want us to look at it further.
  2 个评论
maryam
maryam 2014-10-19
thanks for your reply. signal was recorded by digital oscilloscope.i attached the excel form of that, please download it and help me to choose appropriate parameters. first column is time, second is voltage and third is current signals. thank you very much
Image Analyst
Image Analyst 2014-10-19
Looks more like you just need to delete repeats and outliers than to smooth. See this: http://www.mathworks.com/matlabcentral/fileexchange/3961-deleteoutliers

请先登录,再进行评论。


Jan
Jan 2014-10-19
编辑:Jan 2014-10-19
You can use the faster FEX: fSgolayFilt:
x = rand(1, 2e5);
tic; y = sgolayfilt(x, 3, 4901); toc
tic; y = fSGolayFilt(x, 3, 4901); toc
Elapsed time is 17.458964 seconds.
Elapsed time is 0.719584 seconds.
Matlab 2011b, Win7/64, Core2Duo
But consider Image Analyst's comment. This is an really unusual widow size. But even for shorter windows, the mentioned MEX file helps to save time.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by