Filter löschen
Filter löschen

Deleting complete row having negative integer at any position

1 Ansicht (letzte 30 Tage)
GEOINFORMATICS
GEOINFORMATICS am 3 Okt. 2013
Kommentiert: Sean de Wolski am 14 Okt. 2013
Hi,,, i have a matrix of 596684*4 . at the 4th col of matrix, sometime there appears a -ive number like -2445445, and i want to remove the whole row which contains this number. can anyone help me. Thanks

Antworten (1)

Nishitha Ayyalapu
Nishitha Ayyalapu am 14 Okt. 2013
Here is an example code that would help:
A = [22 33 43 55;
11 22 -33 44;
55 22 33 -44;
99 88 77 66];
[row_neg col_neg] = find(A<0);
A(row_neg,:) = [];
This should manipulate A to
A =
22 33 43 55
99 88 77 66
  1 Kommentar
Sean de Wolski
Sean de Wolski am 14 Okt. 2013
Bearbeitet: Sean de Wolski am 14 Okt. 2013
No reason for find here, logical indexing will work just fine:
A(any(A<0,2),:) = [];

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by