フィルターのクリア

How can I detect constant signal patch from whole signal by using matlab script ?

11 ビュー (過去 30 日間)
Kaustubh hike
Kaustubh hike 2021 年 9 月 17 日
編集済み: Image Analyst 2021 年 9 月 17 日
Hi,
How can I detect constant signal patch from whole signal by using matlab script ? just like shown in red color in in below plot
I would need to detect that constant signal range as well as start and end point ?

回答 (2 件)

KSSV
KSSV 2021 年 9 月 17 日
x = 0:0.1:10;
y = gaussmf(x,[2 5]);
% Introduce constant value
[val,idx] = max(y) ;
idx0 = idx:idx+10 ;
y(idx0) = val ;
% Get the constant data indices
idx1 = find(diff(y)==0) ;
[idx0' [idx1(1)-1 idx1]']
  2 件のコメント
Kaustubh hike
Kaustubh hike 2021 年 9 月 17 日
編集済み: Kaustubh hike 2021 年 9 月 17 日
Thnaks @KSSV, g
But exatcly didnt understand what exatcly your output tells .
KSSV
KSSV 2021 年 9 月 17 日
I have shown the logic....Instead of (x,y) you use your data. It should work fine..If not share your data.

サインインしてコメントする。


Image Analyst
Image Analyst 2021 年 9 月 17 日
編集済み: Image Analyst 2021 年 9 月 17 日
If the constant is fairly flat, and is always in the upper portion (because you are not interested in flat parts near the minimum values at the bottom) you can find the difference and threshold it and use find(). Untested code (because you forgot to attach your data):
subplot(3, 1, 1);
plot(x, y);
grid on;
% Find difference from previous element.
diffValues = diff(y);
subplot(3, 1, 2);
plot(diffValues, 'b-');
% Find max, min, and mid values.
minValue = min(y);
maxValue = max(y);
midValue = (maxValue + minValue) / 2;
% Threshold
threshold = 15; % What ever value defines "flat" for you.
% Find indexes in the upper half that are "flat"
indexes = (y > midValue) & (diffValues < threshold);
subplot(3, 1, 3);
plot(indexes, 'b-');
% Find starting and stopping index
firstIndex = find(indexes, 1, 'first')
lastIndex = find(indexes, 1, 'last')
% Draw vertical lines on the plot
xline(firstIndex, 'Color', 'r', 'LineWidth', 2);
xline(lastIndex, 'Color', 'r', 'LineWidth', 2)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by