how to convert absolute time to real time and calculate the sampling rate

30 views (last 30 days)
Hello to all...In this file, I have the absolute time and date and day of data registration. Now I want to get the real time and calculate the sampling rate from the difference of the frames with each other and their inverse. I have a problem with the MATLAB code. In the first step, I don't know how to calculate the real time and do the next steps? Help me please. Thanks a lot

Accepted Answer

Les Beckham
Les Beckham on 25 Oct 2023
Edited: Les Beckham on 25 Oct 2023
load metaData_Depth
fn = @(s) datetime(s.AbsTime);
dt = arrayfun(fn, metaData_Depth)
dt = 150×1 datetime array
21-Oct-2023 13:51:49 21-Oct-2023 13:51:49 21-Oct-2023 13:51:49 21-Oct-2023 13:51:49 21-Oct-2023 13:51:50 21-Oct-2023 13:51:50 21-Oct-2023 13:51:52 21-Oct-2023 13:51:52 21-Oct-2023 13:51:52 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54
delta_t = seconds(diff(dt))
delta_t = 149×1
0.0209 0.0315 0.0631 0.1337 0.1658 2.5103 0.0901 0.1112 0.2360 0.0295
max(delta_t)
ans = 2.5103
min(delta_t)
ans = 0.0162
numel(unique(delta_t))
ans = 149
mean(delta_t)
ans = 0.0939
std(delta_t)
ans = 0.2075
plot(delta_t, '.')
grid on
So, every single sample has a different duration of time between it and the next sample. Thus, it isn't going to make much sense to calculate a sample rate for this data.
  7 Comments
Voss
Voss on 25 Oct 2023
load metaData_Depth
C = num2cell(vertcat(metaData_Depth.AbsTime),1);
dt = datetime(C{:})
dt = 150×1 datetime array
21-Oct-2023 13:51:49 21-Oct-2023 13:51:49 21-Oct-2023 13:51:49 21-Oct-2023 13:51:49 21-Oct-2023 13:51:50 21-Oct-2023 13:51:50 21-Oct-2023 13:51:52 21-Oct-2023 13:51:52 21-Oct-2023 13:51:52 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:53 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54 21-Oct-2023 13:51:54
delta_t = dt - dt(1)
delta_t = 150×1 duration array
00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 00:00:02 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:03 00:00:04 00:00:04 00:00:04 00:00:04 00:00:04 00:00:04 00:00:04 00:00:04 00:00:04

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!