rows and columns in array
Show older comments
Say I have an array with x amount of rows and 3 columns.
I want to count how many times does a specifc value repeat on the first column. So for example I want to know how many times do numbers 5,6,7,8,9 repeat in the first column. If they repeat less than 4 times then I want to delete the entire row where that value is in the first and/or second column to be deleted.
example: 5 has less than 4 combinations then the following rows would be deleted from the array.
5 1 100
2 5 800
5 5 500
1 Comment
Image Analyst
on 3 Dec 2020
Well fine, but you didn't show us the original matrix with the repeats and the "rows to be removed" in that matrix. What does your original matrix look like? and do you want 5,6,7,8,9 in order and that whole stretch of 5 adjacent numbers is repeated more or less than 4 times? Or do you want to delete rows where 5 is less than 4 times, and 6 is less than 4 times, etc.? The meantime, see ismember(), sum(), etc. And does repeated mean adjacent repeats, like [1,4,4,4,4,5,6] or can the repeat be separated, like [1,4,3,4,6,4,7,4]?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!