Day of year to month
古いコメントを表示
I have a years worth of data in the form of 1-365 (in a column of my matrix), and I want to change it to the days in a month, so I can plot a graph that is quicker to read, rather than having to work out, what month day 100 etc.. belongs to.
I'm sure it's really easy to do but I'm completely out of my depth.
回答 (5 件)
Andreas Goser
2011 年 2 月 9 日
I am not 100% sure, but maybe this example helps you
d2011=734504; % 734504 ist the first day of 2011 - example
v=d2011:d2011+100; % create a vector of 100 days
datestr(v) % see all the dates as strings - use for the figure
datevec(v) % can extract day of month
Claire
2011 年 2 月 9 日
0 投票
4 件のコメント
Brett Shoelson
2011 年 2 月 9 日
Can you show us the form of your data?
Doug Hull
2011 年 2 月 9 日
This is not an answer to the question, please post comments or modify your question.
Jan
2011 年 2 月 9 日
Please show us the code and the error messages.
Claire
2011 年 2 月 9 日
Brett Shoelson
2011 年 2 月 9 日
If you have 365 days, for instance, but no month information, you can simply increment the DAY position in datenum:
mydates = datenum(2011,1,1:365,h,m,s);
Or, if you want the y,m,d,h,m,s:
[y,m,d,h,m,s] = datevec(datenum(2011,1,1:365,h,m,s))
Cheers,
Brett
3 件のコメント
Claire
2011 年 2 月 9 日
Brett Shoelson
2011 年 2 月 9 日
The answer doesn't change; you can specify the hour in the variable h.
Brett
Claire
2011 年 2 月 10 日
Brett Shoelson
2011 年 2 月 10 日
How about this?
D = datevec(datenum(1992,1,1:1/24:365, 0,0,0));
Cheers,
Brett
Walter Roberson
2011 年 2 月 10 日
0 投票
I suspect you can skip all of this trouble and use datetick()
2 件のコメント
Claire
2011 年 2 月 10 日
Walter Roberson
2011 年 2 月 10 日
http://www.mathworks.com/help/techdoc/ref/datetick.html
datetick('x','mmm HH')
カテゴリ
ヘルプ センター および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!