Obtaining the system date down to microseconds.

36 ビュー (過去 30 日間)
Victor Ruiz Escorihuela
Victor Ruiz Escorihuela 2023 年 6 月 26 日
Hello colleagues,
I would like to extract the date from the system but I would like to get it in microseconds. I need this to be able to generate a time axis.
Thank you very much in advance.
Victor.

回答 (1 件)

Rahul
Rahul 2023 年 6 月 26 日
According to the information shared, I believe you can use the following code to obtain the date-time in microseconds
currentTime = datetime('now', 'Format', 'yyyy-MM-dd HH:mm:ss.SSSSSS');
The above code will store the date-time(in microseconds) when you run the code in the currentTime varibale.
Now, to generate a time axis with microsecond precision, you can use the following code:
duration = input('Enter duration: ');
startTime = currentTime;
endTime = startTime + seconds(duration);
timeAxis = startTime:duration(0, 0, 0.000001):endTime;
disp(timeAxis);
You can use this timeAxis for your use case.
  1 件のコメント
Victor Ruiz Escorihuela
Victor Ruiz Escorihuela 2023 年 6 月 26 日
Thank you very much Rahul for your help

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by