필터 지우기
필터 지우기

How can I plot BPM over time using a UTC start time in an epoch.txt file?

조회 수: 2 (최근 30일)
Molly Atkinson
Molly Atkinson 2022년 4월 7일
편집: VINAYAK LUHA 2023년 11월 28일
At the moment, I have BPM plotted against the duration of my ECG device's recording (~90 mins). What I'd like to do is to use a start time I have in UTC from an epoch.txt file outputted by the ECG device (e.g 07:55:14) to be able to plot BPM across the actual time during the session (e.g 07:55:14 - 09:25:14). I'd like to do this so I can identify the time in UTC of peaks in BPM and to average BPM during a period of the session I only readily know in UTC.
I realise I could work out the actual time of a peak by using the time elapsed on my current plots along with the start time in the epoch.txt files but I have lots of ECG data across many sessions which vary in duration with different start times so I'd like to save myself some grief!
I would also like to ultimately automate this process so any help or tips as to how to automate this into a script would be very appreciated too.
Thank you!

답변 (1개)

VINAYAK LUHA
VINAYAK LUHA 2023년 11월 28일
편집: VINAYAK LUHA 2023년 11월 28일
Hi Molly,
I understand that, you have multiple 90 minutes BPM data and their initial UTC start time stored in a file named "epoch.txt". Your objective is to generate a plot depicting BPM against UTC time.
Here is code snippet to convert the time axis of your BPM plot to actual UTC time-
% Read the start time and date from the epoch.txt file
fileID = fopen('epoch.txt', 'r');
startDateTimeStr = fgetl(fileID);
fclose(fileID);
% Convert start time and date to MATLAB datetime format
startDateTime = datetime(startDateTimeStr, 'InputFormat', 'dd/MM/yyy HH:mm:ss');
% Duration of the ECG recording (e.g., 90 minutes)
duration = minutes(90);
% Calculate end time
endDateTime = startDateTime + duration;
% Create a time vector representing the actual UTC time during the session
timeVector = startDateTime:seconds(90*60/5399):endDateTime; % Adjust the time step to match the size of the data
% Plot BPM data against timeVector
plot(timeVector, bpmData);
xlabel('Time (UTC)');
ylabel('BPM');
title('ECG BPM across the session');
Further, you can automate this process for multiple sessions by encapsulating the code in a function and looping through the session files.
Additionally, you can refer to the following documentations for more details about the function used above -
Hope this resolves your query.
Regards,
Vinayak Luha

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by