I have total of 40 years = 40*365 days = 14600 days of rainfall datas. What if I want to represent a total of 40 plots per year, not per day unit?

조회 수: 2 (최근 30일)
p = textread('Rainfall of Busan (11.5.1981 11.5.2021).txt');
dt = 1;
totalL = 14600;
plot(p)
I have total of 40 years = 40*365 days = 14600 days of rainfall datas.
What if I want to represent a total of 40 plots per year, not per day unit? (I want to show the average annual precipitation.)
Could you help me??

채택된 답변

dpb
dpb 2021년 11월 24일
Use
ttP=readtimetable('yourfile');
ttPY=retime(ttP,'yearly','mean');
and magic will happen...
  댓글 수: 5
dpb
dpb 2021년 11월 24일
Not without the data file or at least an example of it...use the paperclikp icon
dpb
dpb 2021년 11월 24일
편집: dpb 2021년 11월 24일
NB: textread is deprecated; use textscan or one of the readXXX routines instead for new code.
If your data file doesn't contain the actual dates, but only the preciptation data, then you'll have to create the date externally somehow or you won't be able to average by year...unless you do have as noted precisely 365*40 records and have ignored the leap years in the data set AND the data do begin on Jan 1 of whatever is the beginning year.
If that is the case, then you can use a time-honored "trick" in MATLAB
Yr0=1960; % an arbitrary start year
PYrMn=mean(reshape(P,40,[])).'; % average by column for the 40 years
yr=Yr0+[0:39].'; % create a year vector
plot(yr,PYrMn) % plot the mean annual by year
You could still make the timetable by
ttP=timetable(P,'TimeStep'],days(1),'StartTime',datetime(Yr0,1,1));
where you read in the precipitation data you have and let timetable build the associated rowtimes date vector for you given the starting time and time step.
There are a zillion ways to get there; it all depends on just what you actually have and then what you want.

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

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