find 2 common values of 3 in row matrix?
Show older comments
HI,
I have a 3 columns and n rows matrix I need to find in this matrix, witch rows own the same 2 values of the 3 as the first row. the values can be in a other column order. then find witch rows own the same 2 values of the 3 as the second row...etc
example: A=[1,2,3;3,2,4;5,6,7;7,6,8]
the first loop must find that row 1 has 2 commun values with row 2. third loop must find that row 3 has 2 commun values with row 4.
1 Comment
Image Analyst
on 30 Jan 2015
Accepted Answer
More Answers (1)
1 Comment
dpb
on 2 Feb 2015
1) Have you preallocated Qnor? If not, that'll help noticeably if sizes are very large
2) Is this not symmetric in the end? If so, running the loop only over the triangular section would cut it roughly in half. Also, the i==j locations are all identities.
Just one minor syntax that won't have any significant impact on speed would be
if voisins(i,1) ~=0 && voisins(i,2) ~=0 && voisins(i,3) ~=0
can be written as
if all(voisins(i,:))
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!