Finding rows with specific values

8 vues (au cours des 30 derniers jours)
Tom Sagar
Tom Sagar le 2 Déc 2021
Modifié(e) : Adam Danz le 6 Déc 2021
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.

Réponses (1)

Adam Danz
Adam Danz le 2 Déc 2021
Use ismember.
idx = ismember(T.month, [10,11,12,1,2,3]);
T(idx,:)
  3 commentaires
Tom Sagar
Tom Sagar le 2 Déc 2021
Monthly_airtemp = data name
idx = ismember(monthly_airtemp, [10,11,12,1,2,3]);
monthly_airtemp(idx,:)
Adam Danz
Adam Danz le 2 Déc 2021
Modifié(e) : Adam Danz le 6 Déc 2021
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by