Converting a timestamp into a value that can be plotted

5 ビュー (過去 30 日間)
TAE KYUNG KIM
TAE KYUNG KIM 2023 年 4 月 18 日
回答済み: Star Strider 2023 年 4 月 18 日
Hi,
I have a timestamp data in the format of '11/04/2022 12:23:58 PM' '11/04/2022 12:24:04 PM' ... etc.
For me to able to convert this in a format where it can be used to plot a voltage as a function of time, it seems like I have to make some changes. I tried some of the methods that can be found online, but they did not seem to apply for the format I have for timestamp.
Any help would be appreiciated!

回答 (1 件)

Star Strider
Star Strider 2023 年 4 月 18 日
A duration array may woirk, although a datetime array would also work.
Perhaps something like one of these —
ts = ['11/04/2022 12:23:58 PM';'11/04/2022 12:24:04 PM'] % Text Time Stamps
ts = 2×22 char array
'11/04/2022 12:23:58 PM' '11/04/2022 12:24:04 PM'
dt = datetime(ts, 'InputFormat','dd/MM/yyyy hh:mm:ss a', 'Format','yyyy/MM/dd HH:mm:ss') % 'datetime' Array
dt = 2×1 datetime array
2022/04/11 12:23:58 2022/04/11 12:24:04
du = diff([dt(1); dt]) % 'duration' Array
du = 2×1 duration array
00:00:00 00:00:06

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by