필터 지우기
필터 지우기

why ismember() does not return correct result

조회 수: 7 (최근 30일)
Stavros Tsimpoukis
Stavros Tsimpoukis 2023년 10월 10일
댓글: Dyuman Joshi 2023년 10월 11일
Hello, I have an original matrix M ( Nx3 ) and another one mat ( Kx3 ). I want to have access to the indicies of rows of the original matrix, M, where the rows of the matrix mat also exist in matrix M. My code is:
idx = find(ismember(M, mat, "rows"))
While most of the rows of mat are correctly returned some rows do not. The common theme is that all of them have the third element equal (1.6).
The array mat:
Rows of array M: ( the row [-2.5 1.65 1.6] exists in the array ! )
Is this a floating point problem ?
Thanks
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 10월 11일
"Is this a floating point problem?"
Yes.
Also, experiment with the 2nd output of ismembertol.

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

채택된 답변

Star Strider
Star Strider 2023년 10월 10일
They may have very small values that are not shown, especially if they are calculated.
Using the ismembertol function will likely do what you want.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by