How to store values of rows in a matrix where the 3rd column is a multiple of 100?

5 visualizaciones (últimos 30 días)
I have a matrix with 3 columns and a large number of rows. In order to reduce the rows, I need to keep the rows whose 3rd column value is a multiple of 100 and store it in as a new matrix. How do I do that?

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 5 de Dic. de 2020
Editada: Ameer Hamza el 5 de Dic. de 2020
Use can use rem() to filter the rows where the third column is multiple of 100 and then use logical indexing
M; % nx3 matrix
idx = rem(M(:,3),100)==0;
M_new = M(idx, :);

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by