how to reshape data with leap year?

조회 수: 2 (최근 30일)
Hydro
Hydro 2017년 10월 19일
댓글: Hydro 2017년 10월 19일
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
Hydro
Hydro 2017년 10월 19일
I just want the yearly average of the data. I thought it would be easy to reshape the daily data into (daily*yearly) and then just take the average. KL! I am using 2017 version.
Walter Roberson
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
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
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';
Hydro
Hydro 2017년 10월 19일
Gotcha. Thanks

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

추가 답변 (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