Borrar filtros
Borrar filtros

Hampel filter (built-in) in matlab 2016b way faster than the one from the file exchange

3 visualizaciones (últimos 30 días)
Hi all,
I am using a 32 bit pc for my analysis, which limits me to matlab 2015. The hampel filter is introduced in matlab 2016.
There is a hampel filter in the file exchange which produced the same results compared to 2016.
https://nl.mathworks.com/matlabcentral/fileexchange/34795-outlier-detection-and-removal--hampel-
However, this filter needs to have the input of the time as well. Not a real problem, but for some reason this filter lasts about 100 seconds (1500000 points) while in matlab 2016 it only lasts a few seconds.
due to privacy I can't use the 2016 pc so I hope there is a solution for this! :)
Greetings Martijn
  3 comentarios
KFrenkie
KFrenkie el 22 de Mzo. de 2017
The example in the file exchange requires a time input. The signal is uniformly sampled (10Hz) and while it uses 3 neighbouring datapoints on each side, its a time window of 7. At least, that's what I think it does..
example: x=[1 2 3 4 5 6 7 8 9 10] data=[1 2 3 15 5 6 7 8 9 10]
In 2016, i can use [filtered]=hampel(data).
in 2015, it requires [filtered]=hampel(x,data).
For a large dataset, the 2015 matlab version, requiring the file-exchange one, takes really long.
Greg Dionne
Greg Dionne el 22 de Mzo. de 2017
OK. Have you tried the MEX file FEX submission that does the uniformly-sampled version? Put it in a directory and do "mex hampelFilter.cpp" and try running it. Hopefully it will compile and work ok.
It seemed to work fine for me:
>> mex hampelFilter.cpp
Building with 'Microsoft Visual C++ 2015 Professional'.
MEX completed successfully.
>> data=[1 2 3 15 5 6 7 8 9 10];
>> hampelFilter(data, 3, 3)
ans =
1 2 3 5 5 6 7 8 9 10

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 22 de Mzo. de 2017
Editada: Jan el 22 de Mzo. de 2017
The main work inside Matlab's hampel function is done in movmad.mexw64, a compiled executable for Windows 64. There is no chance to run it on a 32 bit system.
There is some potential to improve the FEX version. Most of all replacing the moving median filter by a C-mex function. To check if more simplifications are possible:
  • Is your x always 1:numel(data)?
  • Do you use the 'standard' or the 'adaptive' method?

Categorías

Más información sobre Digital and Analog Filters en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by