Finding rows with specific values

I have a martrix with year, month, and two variables. With 7 years worth of data.
year month air temp humidity
2007 10 254.2 446.3
I am trying to subset certain months, 10,11,12,1,2,3. I want the data included in the entire row.
Any idea on how i could do this?
Cheers.

回答(1 个)

Adam Danz
Adam Danz 2021-12-2
Use ismember.
idx = ismember(T.month, [10,11,12,1,2,3]);
T(idx,:)

3 个评论

T.month being my matrix name?
Monthly_airtemp = data name
idx = ismember(monthly_airtemp, [10,11,12,1,2,3]);
monthly_airtemp(idx,:)
I assumed your example below was a table
year month air temp humidity
2007 10 254.2 446.3
If monthly_airtemp is a vector of integers representing months, then your code above should work.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

产品

标签

提问:

2021-12-2

编辑:

2021-12-6

Community Treasure Hunt

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

Start Hunting!

Translated by