how to find intersection point or value between two array????

10 ビュー (過去 30 日間)
suchismita
suchismita 2015 年 8 月 27 日
回答済み: Steven Lord 2015 年 8 月 27 日
I have two array as A and B, where,
A=[1.2222 1.2233 1.3344 1.3354 1.4354]
B=[1.1123 1.2234 1.3254 1.4892 1.5678]
I want 2nd element of A and B to intersect but as A's value is not exact equal to B i am not able to plot my graph. as, A's 2nd value is 1.2233 and B's 2nd value is 1.2234 which is almost equal so i want to put a condition as to search equality till 3rd value after decimal.
please please help me

採用された回答

Matt J
Matt J 2015 年 8 月 27 日
編集済み: Matt J 2015 年 8 月 27 日
AA=floor(A*1000);
BB=floor(B*1000);
find(AA==BB),

その他の回答 (2 件)

Steven Lord
Steven Lord 2015 年 8 月 27 日
Take a look at the ISMEMBERTOL and UNIQUETOL functions.

Star Strider
Star Strider 2015 年 8 月 27 日
One possibility:
roundn = @(x,n) 10.^-n.*round(x.*10.^n);
A=[1.2222 1.2233 1.3344 1.3354 1.4354];
B=[1.1123 1.2234 1.3254 1.4892 1.5678];
ABI = intersect(roundn(A,3), roundn(B,3))
ABI =
1.2230

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by