how to reshape data with leap year?
3 次查看(过去 30 天)
显示 更早的评论
I have 30 years daily data. For reason, i want to reshape the data as days*years (e.g. 365/366, 30). for the year with no leap day it would be easy (reshape(Data,365,[]). how one would do it with leap day included?. see the code I tried but is not working. the data I have is from 1981-2010.
Data=(1:10957)';
R=reshape(Data,[],30); % of course it wont work because of the dimensions
4 个评论
Walter Roberson
2017-10-19
Then there is the old "all entries with the same calendar date must appear in the same row", in which case you get NaN in the middle for each Feb 29 that is not present.
采纳的回答
KL
2017-10-19
编辑:KL
2017-10-19
No need to reshape. Use timetables.
then you can simply use
yearlymeantable = retime(yourtimetable,'yearly','mean')
3 个评论
Walter Roberson
2017-10-19
No, it is producing an average for each year. It has to pick a representative date from each year to associate the average with, because MATLAB does not have a time object that has "year only". If you want just the year to show up, you could use
TT2.t1.Format = 'yyyy';
更多回答(0 个)
另请参阅
类别
在 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!