how to take out specific month from data
Show older comments
sir i have 95 year daily model output rainfall data form 2006-1-1 to 2100-12-31.i want to take out nov to feb which include leap years. i have program for this.this is working perfectly for who does not include leap year but i want to include leap years then please suggest me what will change in this program for this. in between 2006 to 2100 have 24 leap years but my data include only 23 leap years,this is not not include end(last) leap year. this is daily data.sir my precipitaion data size is ( 20x22x34698) (lat,lon.time) for india region.sir please help me. this is include leap years.please help me.thank you
dten = datenum([2006 1 1 ;2100 12 31])
[~,M] = datevec(dten(1):dten(2));
xx = find(ismember(M,[11 12 1 2]));
[m,n,k] = size(prec_all_years1);
ii = cumsum(eomday(2014,1:12));
x0 = rem(0:k-1,365)+1;
xx_logic = x0 <= ii(2) | x0 > ii(10);
p = prec_all_years1(:,:,xx_logic);
max_rainfall = max(reshape(p,m*n,[]));
4 Comments
Azzi Abdelmalek
on 9 Apr 2014
Can you clarify what exactly is your problem? What problems do you have with leap years?
dpb
on 10 Apr 2014
What do you mean by "take out", precisely? You mean you want to remove (or selectively keep) those months' data and ignore the rest? Your M variable and ismember will find those. If you're looking to find the leap years and either keep or discard only them, then do the same kind of thing keeping Y as well and build the logical vector of which year is a leap year for the addressing. That's easily done by
isLpYr=(eomday(Y,2)==29); % logical vector T for Y==leap year
Accepted Answer
More Answers (1)
dpb
on 9 Apr 2014
0 votes
2100 is NOT a leap year; it's the "divided by 100" exception of the "divisible by four" rule. Then there's the 400 yr correction as well but we'll likely not be seeing it.
I am wondering, however, about how you've managed to accumulate daily precipitation data for years from 2015-2100 as yet...
Categories
Find more on Resizing and Reshaping Matrices 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!