How do I find where my data point pairs satisfy both conditions?

4 vues (au cours des 30 derniers jours)
Julia
Julia le 2 Nov 2022
I have a table with two columns and over 3000 rows. I am trying to find at how many points do these two columns satisfy a condition.
For example, I have Column1 and Column2, and I want to know where Column1 or Column2 has a value of X or Y (can be interchangeable).
I believe that I want to do something similar to the excel function COUNTIFS, since I have two conditions that I want to satsify, however I am haveing trouble using "groupcounts" on MATLAB
  1 commentaire
the cyclist
the cyclist le 3 Nov 2022
Your question is not very clear, at least to me.
In addition to describing what you need, I suggest you write out a small example of input and desired output.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 3 Nov 2022
Assuming t is your table and your fields are called Column1 and Column2, and are integers you can do
rowsSatisfyingCondition = (t.Column1 == X) & (t.Column2 == Y);
numRows = sum(rowsSatisfyingCondition);
If they're floating point numbers (instead of integers), use ismembertol instead of ==.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by