Clear Filters
Clear Filters

Converting a timestamp into a value that can be plotted

5 views (last 30 days)
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!

Answers (1)

Star Strider
Star Strider on 18 Apr 2023
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

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!