필터 지우기
필터 지우기

How should I search and also delete in matrix?

조회 수: 1 (최근 30일)
x y
x y 2015년 11월 29일
댓글: x y 2015년 11월 29일
Hy It is existing function for searching in the matrix ...?
I have list (numbers) in ([]x3) matrix. The 3rd columns is only 0 or 1. Based on 3rd columns I want to search in the matrix.
for example:
x: y: index:
------------------------
2 4 0
5 6 0
7 8 1
....etc
If the 3rd element is 0 then get this element and get the x,y number to the other function for the goal. and also set this 3rd index to 1 (1 that means that was used).

채택된 답변

Jan
Jan 2015년 11월 29일
M = [2, 4, 0; ...
5, 6, 0; ...
7, 8, 1];
index = (M(:, 3) == 0);
x = M(index, 1);
y = M(index, 2);
...
M(index, 3) = 1;

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by