How to identify the beginning of another hour and choose 3 rows per hour depending on the value of another metric in another column?
1 次查看(过去 30 天)
显示 更早的评论
Hey everybody!
I want to analyse 24h ECG recordings (that are divided in several files) from several patients and I already have the metrics in struct files. The metrics are analysed each 5 minutes but I need to analyse statistically 10 min in each hour with an overlap of 50% (3 rows per hour). The rows need to be consecutive and depend on a threshold in column 3 (minimum of 50% in each row) so they don't always get chosen every N rows (attached picture). I need to find the mean, maximum and minimum of those 3 rows.
I also have a char event time with the time and date of the beginning of the file, the beginning and end of the intervals I am interested in (attached picture).
Could anyone help me with the easiest/efficient way to analyse all the data?
2 个评论
Rishabh Mishra
2020-9-2
Hi,
Kindly attach the ECG readings file, it would enable me to come up with an efficient solution and help you in the best way possible.
回答(1 个)
Rishabh Mishra
2020-9-3
Hi,
Consider the code given below. Few assumptions that I have made while writing this code are:
- The readings are taken starting 12 at Midnight.
- The ECG readings & it’s columns are stored in ‘M’ matrix.
- The readings consist of 24 x 12 rows.
- The number of readings taken every hour is 12 (as readings are taken every 5 minutes on average)
The code:
% assuming that ECG rreadings are taken starting 12 Midnight
start = datetime(2020,1,1,0,0,0)
% assuming that data is stored in 'M' matrix
% time of reading
time = M(:,1)
% reading value
reading = M(:,2)
% threshold value
threshold = M(:,3)
% traverse each row of the data
for k = 1:numel(time)
i = 0
if (time(k) >= start & threshold(k) >= 50.0)
i = i+1
else
i = 0
end
% if 3 consecutive rows with given requirements are found
if (i == 3)
disp(mean(reading(k-2:k))
disp(min(reading(k-2:k))
disp(max(reading(k-2:k))
start = start + duration(1,0,0)
i = 0
end
end
Hope this helps.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!