How to select multilple months in a time series.
3 views (last 30 days)
Show older comments
f = readtable('Sample data.xlsx')
Kindly help me with code to select January, February, March, April, November and December data as dry season months in a different sheet. Select the remaining months data as wet season in another sheet. Thanks.
0 Comments
Answers (1)
Walter Roberson
on 6 Jan 2022
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/855600/Sample%20data.xlsx';
f = readtable(filename);
[~, m, ~] = ymd(f.Time);
mask = ismember(m, [1:4 11:12]);
dry = f(mask,:);
wet = f(~mask,:);
dry(1:5,:)
wet(1:5,:)
2 Comments
Walter Roberson
on 6 Jan 2022
In my experience, people are more likely to want to group by season -- one dry season, one wet season, one dry season, and so on -- instead of wanting to bunch together all wet in one place, and all dry in another.
See Also
Categories
Find more on Dates and Time 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!