How to delete multiple rows if multiple conditions hold true

2 views (last 30 days)
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 ?

Accepted Answer

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

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!