intersectN2(L1,L2) finds all N1x2 N2x2 common pairs as well as respective indices to common pairs.

バージョン 1.0.0.0 (3.41 KB) 作成者: John BG
intersectN2(L1,L2) finds N1x2 N2x2 common pairs as well as respective indices to common pairs.
ダウンロード: 17
更新 2018/4/8

ライセンスの表示

Function intersectN2 finds all common pairs of input vectors aL1_ and aL2_
call: [U,n1,n2]=intersectN2(L1,L2)
L1 : N1x2 or 2xN1 vector
L2 : N2x2 or 2xN2 vector
U is a N3x2 vector containing all common elements
n1 : index vector common elements L1(n1,:) in L1.
n2 : index vector common elements L2(n2,:) in L2.
the following conditions are staisfied: isequal(L1(n1,:),L2(n2,:))
isequal(U,L1(n1,:),L2(n2,:))
If there are no common errors U n1 and n2 are null contents.

Input Output Restrictions: 1.- The input vectors have to be of dimensions N1x2 N2x2 or 2xN1 2xN2
2.- Strict number of input arguments, only 2, no more than 2 input vectors
3.- Strict amount of output arguments, only 3, no more than 3
Test example:

clear all;close all;clc
L1=randi([-5 5],10,2)
L2=randi([-5 5],20,2)
[U,n1,n2]=intersectN(L1,L2)
U
L1(n1,:)
L2(n2,:)
isequal(L1(n1,:),L2(n2,:))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Author: John Bofarull, any comments to improve this function are welcome
at jgb2012@sky.com or through the Mathworks forum to John BG jgb2012@sky.com
1st release: April 8th 2018.

引用

John BG (2024). intersectN2(L1,L2) finds all N1x2 N2x2 common pairs as well as respective indices to common pairs. (https://www.mathworks.com/matlabcentral/fileexchange/66822-intersectn2-l1-l2-finds-all-n1x2-n2x2-common-pairs-as-well-as-respective-indices-to-common-pairs), MATLAB Central File Exchange. に取得済み.

MATLAB リリースの互換性
作成: R2006b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersRead, Write, and Modify Image についてさらに検索

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0

added comment regarding strict input output number of arguments; 2 and only 2 input arguments, 3 and only 3 output arguments. Removed comment lines