timerange for a given month during different years in a set of data
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi,
I am quite new to MATLAB and I am having some trouble making my code to work. I would appreciate very much your answers.
I have a set of data (data.mat) which contains 7 colums of data, being the first one the date (Jan 2010 to Dec 2019).
I would like to extract the data by months (for example all January months along 2010 and 2019).
I have used this solution to do it manually (I only add for 2 years in the example below)
e= table2timetable(data)
S = timerange ('01/01/2010','02/01/2010');
TT =e (S,:);
S1 = timerange ('01/01/2011','02/01/2011');
TT1=e(S1,:)
Jan = [TT;TT1];
I would like to make a loop over the data to just input years and month. Note that wm01ALL1 is my table with 2010 to 2019 data (data)
years = [2010 2011 2012 2013 2014 2015 2016 2017 2018 2019];
month = 6;

TTa shows the data for June of the last year in the loop instead of the stored data for each year.
댓글 수: 4
Akira Agata
2019년 7월 18일
It's not clear for me what you want to do in your task.
But anyway, if you want to extract specific month ( e.g January ) over many years, you can simply do that by following way.
% Extract January data from a timetable TT
idx = TT.Time.Month == 1;
TT_Jan = TT(idx,:);
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!