필터 지우기
필터 지우기

Signal flatline detection?

조회 수: 24 (최근 30일)
jess Kapin
jess Kapin 2021년 3월 30일
댓글: Star Strider 2021년 3월 30일
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?

채택된 답변

Star Strider
Star Strider 2021년 3월 30일
One option is to use the islocalmin (or related islocalmax) funciton, and set 'FlatSelection' to 'first'.
  댓글 수: 3
Star Strider
Star Strider 2021년 3월 30일
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 2021년 3월 30일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by