Finding rows with specific values

조회 수: 8 (최근 30일)
Tom Sagar
Tom Sagar 2021년 12월 2일
편집: Adam Danz 2021년 12월 6일
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
Tom Sagar
Tom Sagar 2021년 12월 2일
Monthly_airtemp = data name
idx = ismember(monthly_airtemp, [10,11,12,1,2,3]);
monthly_airtemp(idx,:)
Adam Danz
Adam Danz 2021년 12월 2일
편집: Adam Danz 2021년 12월 6일
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.

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

카테고리

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