Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I want to exclude rows with a remainder of 1 when the row number is divided by 9

I got about ten thousand data points from the sensor. This data was extracted as an excel .csv file and loaded using readtable, resulting in a 10093×1 table.

However, the problem I am experiencing is that the 1st, 10th, 19th, etc., of these data are unnecessary values, so I want to exclude them.
I’ve found that these numbers have one thing in common: a row with a remainder of 1 when divided by 9.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can I remove the rows where the divisor with 9 equals 1?

>Solution :

You can do this by using mod() and logical indexing:

idxRemove = mod(1:size(data,1),9) == 1;  % True if remainder after division by 9 is 1
data(idxRemove,:) = [];  % Remove unwanted arrays

You can one-line it for efficiency, since idxRemove isn’t stored in that case:

data(mod(1:size(data,1),9) == 1,:) = [];
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading