Extract consecutive data points between 2 thresholds
3 次查看(过去 30 天)
显示 更早的评论
For a project, i have data in the form of wind speed (m/s) recorded with 1 minute intervals, starting from 2009 through to 2021. For the time of each recording I have created a datetime array in the form of yyyy:MM:dd_HH:mm:ss, and for the wind speed recorded at each minute i have created a double array.
The wind speed ranges from 0 through to 40+ m/s. For the project, any wind speeds above 30m/s will cause damage to some machinery and hence, occurances where windspeed exceeds 30m/s must be recorded. Additionally, for each case where wind speed data exceeds 30m/s, i need to find the time taken (in minutes based on the datetime data) for the wind speed to go from 20m/s to the 30m/s limit. So the extracted data points between 20 and 30 m/s must be consequtive, which will allow me to find the time taken for cases where wind speed gradually increases from 20 to 30 m/s. Im not too fussed on the method used to extract the data with said conditions, so any sort of direction/help would be greatly appreciated.
4 个评论
Walter Roberson
2021-9-8
Should there be a sliding window (what width?) in which the condition is set true if mean() over the window is > 30, or median() over the windows is > 30, or if count of (data>30) is > 1 ?
回答(1 个)
KSSV
2021-9-7
Let t be your dates in datetime format and w be your wind data.
% get indices of wind lying in [20, 30]
idx = w>= 20 & w <= 30 ; % results into logical indexing
t1 = t(idx) ; % extract those dates
w1 = w(idx) ; % extract the wind data
2 个评论
KSSV
2021-9-7
From the obtained dates, calculate the diff, wherever diff is 1, those indices can be picked.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!