Removing part of a cell array
3 views (last 30 days)
Show older comments
Brian Gregory
on 16 Jun 2021
Commented: Walter Roberson
on 16 Jun 2021
Hello.
I have a data table 1441x1 reading as a cell. The data in this cell is "06/15/2021 12:00 AM" and changes in time by the minute to make up the 1441x1 cell.
My goal is to be left with an array of only the times, as such "12:00" "12:01"... and so on. Any help is appreciated.
0 Comments
Accepted Answer
Walter Roberson
on 16 Jun 2021
Why not just convert as-is ?
S = '06/15/2021 12:00 AM'
datetime(S, 'InputFormat', 'MM/dd/yyyy hh:mm a', 'Format', 'yyyy/MM/DD HH:mm')
Note the InputFormat uses hh, which is the code for 12-hour numbering format. The 'a' field accepts AM or PM and informs MATLAB of which 12 hour block.
The OutputFormat I coded to use HH which is the code for 24-hour numbering format.
3 Comments
More Answers (0)
See Also
Categories
Find more on Data Type Conversion 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!