How can I select or extract rows?

조회 수: 1 (최근 30일)
Chris
Chris 2022년 9월 5일
답변: Star Strider 2022년 9월 6일
I have a 9855 * 1 table indicating months.
Such as
1
1
1
2
2
2
3
3
3
. .
12
12
12
1
1
1
2
2
2
...
How can I select or extract June to August?

채택된 답변

Star Strider
Star Strider 2022년 9월 6일
It depends on what the data are (for example, datetime arrays).
Given the problem described —
Months = repmat(ones(3,1) * (1:12), 1, 5);
Data = [Months(:) (1:numel(Months)).']
Data = 180×2
1 1 1 2 1 3 2 4 2 5 2 6 3 7 3 8 3 9 4 10
% Check1 = Data(24:36,:)
Result = Data(6 <= Data(:,1) & Data(:,1) <= 8, :)
Result = 45×2
6 16 6 17 6 18 7 19 7 20 7 21 8 22 8 23 8 24 6 52
Check2 = Result(28:36,:)
Check2 = 9×2
6 124 6 125 6 126 7 127 7 128 7 129 8 130 8 131 8 132
There are other approaches as well. this is likely the simplest.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by