How do I find where my data point pairs satisfy both conditions?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
the cyclist
2022-11-3
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.
回答(1 个)
Image Analyst
2022-11-3
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);
See the FAQ: https://matlab.fandom.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_(or_similar)_not_equal_to_zero?
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!