필터 지우기
필터 지우기

Deleting complete row having negative integer at any position

조회 수: 1 (최근 30일)
GEOINFORMATICS
GEOINFORMATICS 2013년 10월 3일
댓글: Sean de Wolski 2013년 10월 14일
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

답변 (1개)

Nishitha Ayyalapu
Nishitha Ayyalapu 2013년 10월 14일
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
Sean de Wolski
Sean de Wolski 2013년 10월 14일
편집: Sean de Wolski 2013년 10월 14일
No reason for find here, logical indexing will work just fine:
A(any(A<0,2),:) = [];

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by