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 Center および File ExchangeData Type Conversion についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by