필터 지우기
필터 지우기

I Wish to generated a date matrix.

조회 수: 1 (최근 30일)
Jas Gil
Jas Gil 2012년 4월 24일
Hello,
How can I generate a date matrix in which I know the start date let say end of last month (03/31/2012) and I know the frequency say each month end and I know how many rows I want let say 100 rows. than mean size of the matrix will be (100,1).
if the frequency is weekly then how will we generate the date matrix.
Thanks jas

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 4월 27일
n = 100;
DateMat = datemnth('03/31/2012', (0:n-1)');
OR:
DateMat = datenum(2012,4+(0:n-1)',1,0,0,0)-1;
  댓글 수: 2
Jas Gil
Jas Gil 2012년 4월 28일
Thank you very you saved my life.
gil
Jas Gil
Jas Gil 2012년 4월 29일
Hi Andrei,
if the frequency is weekly then how will we generate the date matrix.
Thanks fo your earlier solution it work very well
gil

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 4월 24일
Unfortunately this is not as vectorizable as one might hope. If, however, you apply the change I just posted http://www.mathworks.com/matlabcentral/answers/36444-eomday-extension-for-wrapping-month-numbers then you could use
n = 100;
DateMat = datenum([2012*ones(n,1), 3:3+n-1, eomday(2012,3:3+n-1).']);
Warning: this will not work with the Mathworks-provided eomday!

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by