How to generate a date vactor of weekly intervals.
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
How can I generate a date vactor in which I know the start date let say end of last month (03/31/2012) and I know the frequency say weekly and I know how many rows I want let say 100 rows.
댓글 수: 0
채택된 답변
Patrick Kalita
2012년 4월 30일
start = datenum(2012, 3, 31, 0, 0, 0)
Next, use datenum again to define the interval of 7 days:
offset = datenum(0, 0, 7, 0, 0, 0);
Finally, make a 100-element vector by multiplying the numbers 0 through 99 by the offset and adding them to the start date:
vec = start + (0:99)*offset;
You can verify the results by converting the serial date numbers in vec back to strings:
datestr(vec)
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!