필터 지우기
필터 지우기

Using ismember for each row

조회 수: 3 (최근 30일)
Klemens Schumann
Klemens Schumann 2019년 3월 28일
답변: madhan ravi 2019년 3월 28일
Hi,
I have one Vector A and one Matrix B with the same amount of rows:
A = [1;
3;
5;
5;
4];
B = [2,3,4,5;
1,2,4,6;
2,4,1,2;
4,5,6,2;
1,2,3,4];
I would like to use ismembertol for each row of A and B, such as
for i = 1:size(A,1)
result(i,1) = ismembertol(A(i, 1), B(i, :));
end
Is there any smarter way to do this or is using a for - loop fine?
Thanks in advance!
  댓글 수: 4
madhan ravi
madhan ravi 2019년 3월 28일
편집: madhan ravi 2019년 3월 28일
Why not
any(A==B,2) %?
[comment moved to answer section]
Klemens Schumann
Klemens Schumann 2019년 3월 28일
Works perfectly, thank you!

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

채택된 답변

madhan ravi
madhan ravi 2019년 3월 28일

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by