char array, cell array or string array

조회 수: 3 (최근 30일)
Mohamad Ghaddar
Mohamad Ghaddar 2020년 12월 27일
댓글: Mohamad Ghaddar 2020년 12월 28일
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일
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개)

카테고리

Help CenterFile Exchange에서 Geodesy and Mapping에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by