How to delete columns of a matrix containing specific values in bottom row

Hi. I am working on a program that generates a 2xN matrix that looks something like this
ModRows = [7 11 21 27 243 2817 3114 3489;...
2 2 4 6 13 279 1 150]
What I want to do is search the matrix for values in the second row that are below 2 and delete the respective column, so I would get something like this, for example:
ModRows = [21 27 243 2817 3489;...
4 6 13 279 150;]
I have no idea where to start. I can't use an index i from 1 to the size of ModRows, because whenever I delete a column, ModRows becomes shorter, resulting in an error.
Any help would be much appreciated!
Marc

 Respuesta aceptada

per isakson
per isakson el 21 de Sept. de 2013
Editada: per isakson el 21 de Sept. de 2013
Test this:
is_exclude = ModRows(end,:) < 2;
ModRows( :, is_exclude ) = [];
or did you mean "<= 2"?
And search for "Using Logicals inArray Indexing" in the help

Más respuestas (0)

Categorías

Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.

Preguntada:

el 21 de Sept. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by