필터 지우기
필터 지우기

split numbers into coloumns

조회 수: 1 (최근 30일)
Sahar khalili
Sahar khalili 2022년 12월 12일
댓글: Jan 2022년 12월 12일
Hello all
I have a raw of data with 16 digits like 0799569419940319, the last 8 digits are the year, the month and the day. How can I split the cells to extract the year and month and day?
  댓글 수: 4
Star Strider
Star Strider 2022년 12월 12일
Consider:
n = 0799569419940319;
ns = num2str(n);
dn = ns(end-7:end) % Date Segment
dn = '19940319'
nn = ns(1:end-8) % Number Segment
nn = '7995694'
DT = datetime(dn, 'InputFormat','yyyyMMdd') % 'datetime' Vector
DT = datetime
19-Mar-1994
I hav no idea what the rest of these numbers are, so I cannot generalise this and so am not posting this as an Answer.
.
Jan
Jan 2022년 12월 12일
The leading zero let me assume, that this is not a number, but a CHAR vector. But if it is really a number:
n = 0799569419940319;
day = rem(n, 100)
day = 19
month = rem(floor(n / 100), 100)
month = 3
year = rem(floor(n / 10000), 10000)
year = 1994

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by