Borrar filtros
Borrar filtros

Signal flatline detection?

24 visualizaciones (últimos 30 días)
jess Kapin
jess Kapin el 30 de Mzo. de 2021
Comentada: Star Strider el 30 de Mzo. de 2021
Hello!
I am working with a few signals in matlab and want the code to detect when the signal line flattens out.
Any ideas as to how to go about this?

Respuesta aceptada

Star Strider
Star Strider el 30 de Mzo. de 2021
One option is to use the islocalmin (or related islocalmax) funciton, and set 'FlatSelection' to 'first'.
  3 comentarios
Star Strider
Star Strider el 30 de Mzo. de 2021
My pleasure!
Another option would be to use the gradient function to calculate a numerical derivative, then threshold it to detect a 0 derivative. The only problem with that is that it could also detect peaks or valleys in an oscillating signal, so since I have no idea what the signal looks like, I am sugesting it as an alternative only.
The derivative would be calculated as:
dydx = gradient(y) ./ gradient(x);
assuming here that both are vectors.
Star Strider
Star Strider el 30 de Mzo. de 2021
If the arguments are vectors, yes.
For example:
v = [5 3 9 2 NaN 4 7 6 Inf 1 8 5]
v = v(isfinite(v))
If they are 2D (or greater dimension) arrays, this is more difficult because ‘empty’ entries are not permitted in numeric arrays. Every position must have some value, with NaN being the default for missing data. Removing isolated values (a opposed to rows or columns) destroys the matrix structure. Cell arrays can have empty entries, however before using them in numeric computations, the values must be recovered from the cell arrays (since cell arrays can contain anything), so the problem recurs.
So again, if the data are vectors, this would work:
x = [5 3 9 2 NaN 4 7 6 Inf 1 8 5]
y = randi(9, size(x))
L = isfinite(x)
xc = x(L)
yc = y(L)
If you have specific data and you would like to share them, please upload them.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by