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?

1 次查看(过去 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
编辑: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 中查找有关 Data Type Conversion 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by