Sorting/Grouping based on date for all years
1 view (last 30 days)
My attached data is continous from 1st Jan to 31st Dec for 5 years(2001-2005). I want to compare the data (For eg: Minimun, Maximum, Percentile) from 27th Sept to 27th Oct for particular year- 2004 with all the years within that range(27-09 to 27-10) on same plot. How can I to group the data for all years but only from 27th Sept to 27th Oct and perform the required operations (For eg: Minimun, Maximum, Percentile) ?
Chunru on 24 Jun 2022
x = readtable("Example.xlsx");
x1 = x(x.Var1>=datetime(2004, 09, 27) & x.Var1<=datetime(2004, 10, 27), :);
md = datetime(0, month(x.Var1), day(x.Var1));
x2 = x(md >= datetime(0, 09, 27) & md <= datetime(0, 10, 27), :);
More Answers (1)
Eric Sofen on 24 Jun 2022
The isbetween function can also help simplify a lot of the logical indexing to pull out the ranges of interest.
tt = readtimetable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1043805/Example.xlsx");
ind = any(isbetween(tt.Time,datetime(2001:2005,9,27),datetime(2001:2005,10,27)),2);