How to padd numbers with leading zero or to convert to two digits in cell array, string array or char arrays?
5×16 char array
'2020-01-1-11-15'
'2020-02-5-12-5 '
'2020-04-25-10-30'
'2020-07-15-3-15 '
'2020-12-3-17-6 '

1 件のコメント

Mohamad Ghaddar
Mohamad Ghaddar 2020 年 12 月 27 日
for examle convert '2020-1-11-5' to 2020-01-11-05'

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

 採用された回答

Walter Roberson
Walter Roberson 2020 年 12 月 28 日

0 投票

C = ['2020-01-1-11-15 '
'2020-02-5-12-5 '
'2020-04-25-10-30'
'2020-07-15-3-15 '
'2020-12-3-17-6 ']
C = 5x16 char array
'2020-01-1-11-15 ' '2020-02-5-12-5 ' '2020-04-25-10-30' '2020-07-15-3-15 ' '2020-12-3-17-6 '
char(datetime(cellstr(C), 'InputFormat', 'uuuu-M-d-H-m', 'Format', 'uuuu-MM-dd-HH-mm'))
ans = 5x16 char array
'2020-01-01-11-15' '2020-02-05-12-05' '2020-04-25-10-30' '2020-07-15-03-15' '2020-12-03-17-06'

1 件のコメント

Mohamad Ghaddar
Mohamad Ghaddar 2020 年 12 月 28 日
thans a lot for your promt answer, it worked out!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Data Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by