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 Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by