필터 지우기
필터 지우기

How to add columns with month number and day

조회 수: 2 (최근 30일)
Ede gerlderlands
Ede gerlderlands 2013년 2월 19일
Hi
I have daily observation data which runs for 8 years. The beginning of the data is 1St of January 2000 and ends on 30 April 2007. I wanted to add two columns which are number of month ( Jan=1, feb=2 etc) and number of days(January 1 to 31, February (1 to 28 or 29)). Each four year the number of days in February will be changed. Can you help me with this.
I highly appreciate your help.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 19일
편집: Azzi Abdelmalek 2013년 2월 19일
a=datenum(2000,1,(1:7*365+122))
v=datevec(datenum(a))
col_month=v(:,2)
col_day=v(:,3)
If you want your date in other format
yourdates=datestr(datenum(2000,1,(1:7*365+122)),'dd-mmm-yyyy')
  댓글 수: 3
Ede gerlderlands
Ede gerlderlands 2013년 2월 19일
Thank you very much...
Andrei Bobrov
Andrei Bobrov 2013년 2월 19일
편집: Andrei Bobrov 2013년 2월 19일
[~,M,D] = datevec(datenum...
(2000,1,1+(diff(datenum([2000 1 1;2007 4 30])))',0,0,0));
out = [M,D];

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by