Time format/Repeating Times in a table

5 ビュー (過去 30 日間)
Noush
Noush 2021 年 11 月 1 日
回答済み: Cris LaPierre 2021 年 11 月 1 日
I have a table with time values written like this: 0830 for 08:30 AM. How can I change the format, so that Matlab recognizes that this is a time and not a number?
Next, I'd like to plot values for each of these times in a graph. The values change, but the times repeat because there are only 24 hours in a day obviously. How can I plot the values after each other and not on top of each other for the different days?
Thank you so much for help on either problem.

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 11 月 1 日
Covert your times to strings (keeping the leading zeros), and then use datetime to convert..
T = 0830;
T = sprintf('%04d',T)
T = '0830'
dur = datetime(T,'InputFormat','HHmm','Format','h:mm a')
dur = datetime
8:30 AM

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by