Hi!
I'm trying to create a loop that, having two vectors (A and B) of different size (nx1 and mx1), for the first observation in A to search over all the observations in B and return the index of those values who have a similar (plus or less 2%) of the original value in A. Same procedure for the rest of values in A.
My loop is the following, but honestly, I can't find a way to do this.
for j = 1:m
[e,indexes] = find(A(j) >= 0,98*B(:) & A(j) <= 1,02*B(:));
end

回答 (1 件)

Star Strider
Star Strider 2018 年 4 月 30 日

0 投票

If I understand correctly what you want to do, the ismembertol (link) function is likely appropriate.
You will have to define an absolute tolerance, not a percent tolerance.

カテゴリ

ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索

タグ

質問済み:

2018 年 4 月 30 日

回答済み:

2018 年 4 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by