How to delete multiple rows if multiple conditions hold true

I am trying to delete rows from a matrix, named CDF_stand_init, if they contain any column value >3 or <-3 I am trying this
c1 = CDF_stand_init (:,:) >3
c2 = CDF_stand_init (:,:) < -3
C = c1 | c2
CDF_stand_init(C,:) = []
but it produces the following error: Index of element to remove exceeds matrix dimensions at
CDF_stand_init(C,:) = []
how can I resolve it ?

 Réponse acceptée

You need to use any to reduce your 2d logical array to a column vector.
C = any(c1 | c2, 2);
CDF_stand_init(C, :) = []

Plus de réponses (0)

Catégories

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by