- To check how many times a number repeats in a particular row or column.
- Delete that row or coumn if the count is less than 4.
rows and columns in array
4 views (last 30 days)
Rachel Ramirez on 3 Dec 2020
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
Swetha Polemoni on 7 Dec 2020
Hi Rachel Ramirez,
It is my understanding that you want
A=randi(5, 10 ,10); % generating a random matrix with dimension 10X10
for i= 1:10
count=sum(A(j,:)==5); % counting number of times 5 is repeting in jth row
A(j,:)=; % deleting jth row if count is less than 4
Hope this helps.