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

4 visualizzazioni (ultimi 30 giorni)
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 Commento
the cyclist
the cyclist il 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.

Accedi per commentare.

Risposte (1)

Image Analyst
Image Analyst il 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:

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by