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

30 次查看(过去 30 天)
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

采纳的回答

Les Beckham
Les Beckham 2023-10-25
编辑:Les Beckham 2023-10-25
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 个评论
Voss
Voss 2023-10-25
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by