delete and handling matrix

조회 수: 2 (최근 30일)
Giuseppe Antonacci
Giuseppe Antonacci 2019년 2월 18일
댓글: Adam Danz 2019년 2월 18일
hi,
I have matrix in the insert.I would like:
1) a cycle if/for that if MAtrix(:,8)<3 and matrix(:,6) different zero, delete this line in the matrix.
2)a cycle for/if that IF matrix (:,8)<3 in this lines matrix(:,6) must be 0.
thanks bye

채택된 답변

Adam Danz
Adam Danz 2019년 2월 18일
To identify rows of a matrix where column 8 is less than 3 and column 6 is not zero,
rowIdx = (matrix(:,8) < 3) & (matrix(:,6) ~= 0);
where 'rowIdx' is a vector of row numbers that satisfy those conditional statements.
To remove those rows from the matrix,
matrix(rowIdx, :) = [];
To identify rows of at matrix where column 8 is less than 3 and column 6 is equal to zero,
rowIdx2 = (matrix(:,8) < 3) & (matrix(:,6) == 0);
  댓글 수: 2
Giuseppe Antonacci
Giuseppe Antonacci 2019년 2월 18일
thanks, one other thing:
a cycle for example
if matrix(:,8)<3
matrix(:,6)=0
end
but this doesn't works.
Adam Danz
Adam Danz 2019년 2월 18일
I'm not sure what you mean by 'a cycle'.
Please look at my 3rd line of code to see how I constructed that line. You must use two equal signs.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by