Moving window with two conditions - Matlab

1 回表示 (過去 30 日間)
Ganesh Naik
Ganesh Naik 2019 年 11 月 6 日
コメント済み: Ganesh Naik 2020 年 7 月 30 日
I have a time series data with the amplitude of the values range from 1 to 100. I need to use a moving window (10 seconds duration) and flag/highlight the segments of the data that falls with the threshold range of 91 to 97 for at least 10 seconds or more.
Any help in this regard is highly appreciated.
Thanks in advance
  2 件のコメント
Ajay Kumar
Ajay Kumar 2019 年 11 月 6 日
Having data would be helpful.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 6 日
See diff with time series condition

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

回答 (1 件)

Ayush Gupta
Ayush Gupta 2020 年 6 月 5 日
Try following this approach, it returns the regions in the moving window in between the defined thresholds:
% Define sample data and the threshold values.
A = count1.Data.';
threshold1 = 12;
threshold2 = 21;
moving_window = 10;
% Find logical vector where A>=hreshold1 and A<=threshold2
binaryVector = (A >= threshold1) & (A<=threshold2);
% Label each region with a label - an "ID" number.
[labeledVector, numRegions] = bwlabel(binaryVector);
% Measure lengths of each region and the indexes
measurements = regionprops(labeledVector, A, 'Area', 'PixelValues');
% Find regions where the area (length) is greater or equal to moving
% window and put the values into a cell of a cell array
ca = {};
for k = 1 : numRegions
if measurements(k).Area >= moving_window
ca{end+1} = measurements(k).PixelValues;
% Area (length) is greater or equal to moving window, so store the values.
end
end
% Display the regions that meet the criteria:
celldisp(ca)
  1 件のコメント
Ganesh Naik
Ganesh Naik 2020 年 7 月 30 日
Hi Ayush thanks for the answer. Could you please help me to plot these regions and shade them.

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

Community Treasure Hunt

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

Start Hunting!

Translated by