How the function "velodyneFileReader" calculate the start time of pcap file in matlab ?

1 次查看(过去 30 天)
Hello !
How we can calculate the start time of the pcap file by using function "velodyneFileReader", i see an example in the documentation but i didn't understand it ,
if the file is recorded for 7 minutes from 1:58 p.m. to 2:05 p.m., then:
  • StartTime = 58 min × 60 s = 3840 s
if we suppose we have time such as "1:58:04 p.m" so how we calculate start time ?
Thanks in advance

回答(1 个)

Paras Gupta
Paras Gupta 2023-10-19
Hi Sara,
I understand that you want to know the specific calculation used by the 'velodyneFileReader' function in MATLAB to determine the start time of a pcap file.
The 'velodyneFileReader' function calculates the start time relative to the previous whole hour. It uses the number of minutes elapsed since the previous whole hour to determine the start time in seconds.
For example, let's say you have a recording that starts at 1:58:04 p.m. and ends at 2:05:04 p.m. To calculate the start and end times relative to the previous whole hour, you need to consider the hour before the start time, which in this case is 1 p.m. The start time is calculated by determining the number of seconds elapsed from the previous whole hour until the actual start time. In this case, it would be 58 minutes and 4 seconds, that is 58 * 60 + 4 seconds, which gives you 3484 seconds. The end time is then calculated by adding the duration of the recording (in this case, 7 minutes multiplied by 60 seconds) to the start time.
You can refer to the following code to achieve the same programatically in MATLAB.
% Extract minutes and seconds from the given time
time = "1:58:04 p.m.";
timeComponents = split(time, ':');
minutes = str2double(timeComponents{2});
seconds = str2double(extractBefore(timeComponents{3}, ' '));
% Convert minutes to seconds and add the seconds to calculate start time
startSeconds = minutes * 60 + seconds;
% Calculate end time by adding the duration (7 minutes in this case) to start time
durationMinutes = 7;
endSeconds = startSeconds + (durationMinutes * 60);
disp("Start time in seconds: " + startSeconds);
Start time in seconds: 3484
disp("End time in seconds: " + endSeconds);
End time in seconds: 3904
Please find below the documentation links to the functions used in the code above:
Hope this helps.

类别

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

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by