why ismember() does not return correct result

11 ビュー (過去 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 Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by