Using ismember with some margin

4 ビュー (過去 30 日間)
Reuben Addison
Reuben Addison 2023 年 5 月 3 日
編集済み: Jon 2023 年 5 月 3 日
I asked a question yesterday and I got some good answers but there was a twist to my problem want to use a subset of number to find the index in a bigger set, my smaller set has some margin of error +/- 0.001
eg bigger set BS = [2.33, 4.551, 5.88, 3.98, 4.661, 7.98, 2.331, 9.55]
smaller set SS = [4.55 4.66 7.99]
I want to use the smaller set (SS) to pick the index of its location in the bigger set (BS)
I tried using find, ismembertol but not working well
I will be happy to figure this out
  1 件のコメント
Jon
Jon 2023 年 5 月 3 日
Would be better to preserve the history and responses so far to continue your original post with this as a comment, rather than opening up a new question.

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2023 年 5 月 3 日
ismembertol by default uses relative tolerances. To use absolute tolerance with it you need to set the relative portion to 1 and use one of the named options to set the margin to the absolute value you want.
  1 件のコメント
Walter Roberson
Walter Roberson 2023 年 5 月 3 日
Sorry details were slightly wrong, see https://www.mathworks.com/help/matlab/ref/ismembertol.html#bup2c1a

サインインしてコメントする。


Jon
Jon 2023 年 5 月 3 日
編集済み: Jon 2023 年 5 月 3 日
You can use ismembertol for this
SSnoisy = SS + randn(size(SS))*0.01
idx = find(ismembertol(BS,SSnoisy,0.05))

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by