find 2 common values of 3 in row matrix?
显示 更早的评论
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 个评论
Image Analyst
2015-1-30
采纳的回答
更多回答(1 个)
1 个评论
dpb
2015-2-2
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,:))
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!