フィルターのクリア

Return row and col of ismembertol comparisons?

3 ビュー (過去 30 日間)
Andrew Poissant
Andrew Poissant 2017 年 9 月 4 日
編集済み: Andrew Poissant 2017 年 9 月 4 日
I have a layered matrix, N, that is 834x834x3 and I want to scan that matrix using ismembertol to see which ordered pairs from F are in N and then return the row and col for each match. Matrix F is 93x2. I have my attempt at it below but it does not work properly and I do not think find is the function I need. I did not define the matrices N and F because they are defined using previous code. I know I need to use something like ismembertol(...) & ismembertol(...) to scan matrix N for common values between it and F but I am not sure how to return the row and col. Any suggestions?
[r, c] = size(F);
tol = 1;
for i = 1:r
[row(i), col(i)] = find(ismembertol(F(i,1), N(:,:,2), tol) & ismembertol(F(i,2), N(:,:,3), tol))
end

回答 (1 件)

KSSV
KSSV 2017 年 9 月 4 日
A = rand(3,3,3) ;
B = rand(2,2,3) ;
%%find values equal to 0.5
[LIA,LocAllB] = ismembertol(B, A, 0.1)
LIA returns an array containing logical 1 (true) where the elements of B are within tolerance 0.1 of the elements in A.
LocB contains the index location in A for each element in B that is a member of A.
  3 件のコメント
KSSV
KSSV 2017 年 9 月 4 日
Yes....that's what LIA and LOCB gives you...
Andrew Poissant
Andrew Poissant 2017 年 9 月 4 日
編集済み: Andrew Poissant 2017 年 9 月 4 日
I am confused. I have the matrix F that is being used for ismembertol versus two layers of matrix N. I do not see where the matrix F (not layered) is set up and compared to to the two different layers of N. I see that you set up two 3 layered matrices and compared the two but I am comparing one column of matrix F to second layer of N and the second column of F to the third layer of N. Am I missing something in your solution?

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

カテゴリ

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