I having two time series one is monthly and another one is in daily, now i need to average the daily time series to the particular time values of monthly time series
Show older comments
the sample time series is such that
for monthly: 2004.0438 1.975
2004.126 2.985
...............................
for daily : 2004.001360 .00567
2004.004100 .00458
................................
now i want to get the monthly average from daily time series whose time value should {whose time column should} match with the monthly time series, ie in monthly average of daily time series I need the time value as 2004.0438 2004.126 just as monthly time series
16 Comments
Yona
on 16 Sep 2014
What is the time you write?
In matlab each day is 1. for example today it 73586 and tomorrow will be 73587. so month need to be in difference of 28, 30 or 31.
Chris Martin
on 16 Sep 2014
Chris Martin
on 16 Sep 2014
You can take the average of all time that are the same natural number after multiply by 365.
if X is in year, take average of all data that have the same month (second data) in:
datevec(X*365)
Chris Martin
on 16 Sep 2014
Chris Martin
on 16 Sep 2014
Doesn't look like enough precision that will match and don't appear to be any even increments...
What, specifically, does ...monthly average of daily data set....having same time as monthlytime series mean?
The dates given look like
>> dm=[2004.0438;2004.126];
>> y=fix(dm);
>> mdy=dm-y;
>> datestr(datenum(y,1,1)-1+mdy*365)
ans =
15-Jan-2004 23:41:16
14-Feb-2004 23:45:36
>>
Those aren't any even values; so it'll be difficult I'd guess to find a precise set of values that match. How many daily values are there per monthly set--are the monthly averages actual averages by month of varying days/month at some more-or-less random point or what? Doesn't seem to be any consistent pattern to use.
Chris Martin
on 17 Sep 2014
David Young
on 17 Sep 2014
Do you want the mean to be the mean of the values that fall within a given calendar month (e.g. all the values in January 2004), or all the values that fall within, say, 15 days of the time at the centre of the month, or some other definition?
Chris Martin
on 17 Sep 2014
David Young
on 17 Sep 2014
Edited: David Young
on 17 Sep 2014
Another question: the decimal year format is not well-defined because of leap years. To get from the fractional part to the number of days from the start of the year, should we multiply by 365.25 in all cases, or by 366 in leap years and 365 in other years?
David Young
on 17 Sep 2014
OK, let me try and ask another way. The second monthly time is 15 Feb 2004 at 00:30 if you assume there are 365.25 days in a year even in 2004 (a leap year). For the corresponding mean, do you want to average all the events 15 days either side (from 00:30 on 31 January to 00:30 on 1 March), or do you want all the events in February?
Chris Martin
on 17 Sep 2014
David Young
on 17 Sep 2014
Edited: David Young
on 17 Sep 2014
I'm sorry, I can give you a solution, and so could dpb, but we need to know which solution you would like. I think maybe you don't understand my questions, but I've put them as clearly as I can. Last try:
- Do you want the averages to be over calendar months, or over fixed time periods centred on the monthly reading times?
- Does a fraction of a year mean the number of days divided by 365.25 always, or the number of days divided by 366 in leap years and 365 in other years?
dpb
on 17 Sep 2014
Does a fraction of a year mean the number of days divided by 365.25 always, or the number of days divided by 366 in leap years and 365 in other years?
Or the third alternative of 365 days always???
Or, perhaps the fourth -- "I don't know; pick one"
Answers (1)
Yona
on 17 Sep 2014
find the value of middle of month by
m=1:12;
d=[1 0 1 0 1 0 1 1 0 1 0 1];
mid = datenum(0,m,15+d)/365
when m is the month and 16 or 15 depend if the month have 30 or 31 days.
To take the mean of data, find the value of month:
str = datenum(0,m,1)/365;
and then look on mdy. if it between str(1) -> str(2) it in january. ext.
1 Comment
Chris Martin
on 17 Sep 2014
Categories
Find more on Time Series Events in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!