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

版本 1.0.0.0 (3.4 KB) 作者: John BG
intersectN2(L1,L2) finds N1x2 N2x2 common pairs as well as respective indices to common pairs.
16.0 次下载
更新时间 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 CenterMATLAB Answers 中查找有关 Read, 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