フィルターのクリア

how to find the closest values with tolerance in a matrix given a specific value

122 ビュー (過去 30 日間)
Hi everyone, i have a problem finding values with tolerance in a matrix.In more detail, i have a 601x2201 matrix that contains option values, all i want is to find the closest values to 185.2 with +-0.02 tolerance and their indexes in the matrix.i have tried some codes to solve this(ismember,find,...) but always i end up with no answer.i would appriciate any help.Thank you for your time.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 9 月 6 日
A=1000*rand(601,2201) ; % Example
tol=0.02
th=185.2
[ii,jj]=find(abs(A-th)<tol)
size(ii)

その他の回答 (1 件)

kostas zervos
kostas zervos 2016 年 9 月 6 日
Thank you guys,you saved me!!!both answers are very helpful!!!
  1 件のコメント
michio
michio 2016 年 9 月 6 日
編集済み: michio 2016 年 9 月 6 日
If you are using R2015b or later, ismembertol function could also be of help.

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

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by