How can I plot hourly data in the same figure?

2 ビュー (過去 30 日間)
Suat YAZICI
Suat YAZICI 2019 年 4 月 4 日
コメント済み: dpb 2019 年 4 月 7 日
My data as follows:
  • 1st column: Year
  • 2nd column: Day of the year
  • 3st column: Hour
  • 6st column: Value
I'd like to do statistic analysis such as median, minimum, maximum, and mean for every season and then plot in the same figure. Problem is that hour column is not at regular intervals for me. That's why output figure is not what I want.
  2 件のコメント
dpb
dpb 2019 年 4 月 5 日
So what do you want?
Suat YAZICI
Suat YAZICI 2019 年 4 月 5 日
Hour value is irregular. It changes its interval in related to years. For example, interval hour of 1st winter season is between 1 and 23 by increasing 2 but my code plots 0 value and there is no 0 value in this data.
I would like to do hourly variaton according to winter season in this data by calculating statistic analysis and then plotting it in the same figure according to its own hour values.

サインインしてコメントする。

採用された回答

dpb
dpb 2019 年 4 月 5 日
編集済み: dpb 2019 年 4 月 5 日
Use the features of Matlab to your advantage...granted, it takes some "time in grade!" to learn one's way around! :)
As a general rule, when one finds that are building specific indices into the data, that's a real sign there should be a better way...in this case, converting to datetime in order to do the comparisons is the trick. And, it turns out your Q? immediately follows essentially the same problem in financial analysis and is quite common also with such data as yours...the same 'trick" as used there (link) works very well here as well--
load winter.txt
w=table(datetime(winter(:,1),1,winter(:,2),winter(:,3),0,0),winter(:,6) ...
'VariableNames',{'Date','Data'}); % create table from array
w.WYear=fix((w.Date-w.Date(1))./duration(24*365+isleapyr(w.Date),0,0)); % compute the winter year
yr=unique(year(w.Date)); % retrieve the years covered
yrlabel=cellstr(num2str([yr mod(round(100*(yr/100-fix(yr/100)))+1,100)],'%d-%02d')); % build a label array
labels={'Winter','Mean','Median','Minimum','Maximum','StdDev','LowLimit','UpLimit'}; % output statistics
g=findgroups(w.WYear); % grouping variable by winter
[av,md,mn,mx,sd,lo,hi]=splitapply(@multipleStatistics,w.Data,g); % compute statistics
summ=table(categorical(yrlabel),av,md,mn,mx,sd,lo,hi,'VariableNames',labels); % build a summary table
>> summ =
summ =
20×8 table
Winter Mean Median Minimum Maximum StdDev LowLimit UpLimit
_______ ______ ______ _______ _______ ______ ________ _______
1998-99 17.909 14.9 4.1 51 10.114 4.3556 31.462
1999-00 21.358 18 3.4 63.2 13.36 3.4553 39.26
2000-01 22.821 19.75 5.3 60.7 13.627 4.5608 41.082
2001-02 38.467 34.45 5.3 92.5 20.885 10.481 66.453
2002-03 20.464 16.1 3.8 60.6 11.386 5.2074 35.721
2003-04 14.101 11.3 3.9 45.2 7.4069 4.1757 24.026
2004-05 11.731 10.1 0.2 31.2 5.4401 4.4414 19.021
2005-06 10.189 9.4 3.3 25.6 3.3511 5.6982 14.679
2006-07 9.063 8.1 0.7 19.8 3.1426 4.8519 13.274
2007-08 8.5001 8 3.2 22.2 2.6795 4.9095 12.091
2008-09 8.7789 8.6 2.8 17.9 2.3483 5.6322 11.926
2009-10 9.8379 9.5 2.8 25 3.2059 5.542 14.134
2010-11 10.533 10.05 3.5 35.4 3.7726 5.4773 15.588
2011-12 15.377 13.55 3.3 41.7 6.7471 6.3357 24.418
2012-13 13.316 11.5 3.2 41.1 5.8716 5.4482 21.184
2013-14 18.659 16.3 4 60.8 9.9698 5.2995 32.019
2014-15 20.451 17.1 5.1 50.9 10.52 6.3538 34.548
2015-16 12.464 10.7 3.3 34.8 5.6957 4.8319 20.096
2016-17 9.2583 8.5 3.6 23.9 3.185 4.9904 13.526
2017-18 8.8444 8.5 4.1 17 2.4073 5.6186 12.07
>>
  23 件のコメント
Suat YAZICI
Suat YAZICI 2019 年 4 月 7 日
Thank you so much for patient, kind and explanation.
dpb
dpb 2019 年 4 月 7 日
'tis OK, I enjoy interaction with those who are trying...and am known for prodding sometimes instead of just answering straight out to hopefully end up with more learning in the process...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalendar についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by