필터 지우기
필터 지우기

How to get the indices based on month and year?

조회 수: 3 (최근 30일)
Shayma Al Ali
Shayma Al Ali 2023년 4월 3일
댓글: Stephen23 2023년 4월 3일
I have an array of data, "B", with a corresponding datetime array. The data spans between 2018-2022 but its not uniformly distanced so some months have more data than others. My plan is to loop through the data, get the data that corresponds to a month and year (ex. Jan 2020) and run some functions, and then get the data that corresponds to the next month and year, and repeat.
Is there any way I can do it more efficiently? Any functions where I can categorize the data by month and year?

답변 (1개)

Walter Roberson
Walter Roberson 2023년 4월 3일
You can use timerange
But if you want to group by month, then typically it is easier to do something like take
[y, m] = ymd(DATETIMES);
G = findgroups(y, m);
Now you can use G together with splitapply
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 4월 3일
Also, you should check to see if using retime could be used for your situation.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by