I am trying to compare two matrices of length 2xn and 2xm for n>m. For example consider n=19,m=16. Then we have the following two vectors, nodes (2×19) and old_nodes (2×16).
%Nodes Old_nodes
0 0 0 00 0.333333333 0 0.3333333330 0.666666667 0 0.6666666670 1 0 10.333333333 0 0.333333333 00.333333333 0.333333333 0.333333333 0.3333333330.333333333 0.666666667 0.333333333 0.6666666670.333333333 1 0.333333333 10.666666667 1 0.666666667 01 0.666666667 0.666666667 0.3333333331 1 0.666666667 0.6666666671 0.166666667 0.666666667 10.666666667 0 1 01 0 1 0.3333333330.833333333 0.166666667 1 0.6666666670.666666667 0.666666667 1 00.666666667 0.333333333 1 0.333333333 0.833333333 0.333333333
From here I am then trying to find out which rows in nodes are in old_nodes, there should be 16 of them. However, my attempt does not yield any effective results. I have tried the following, by taking four elements that i know are in old_nodes (rows: 6 7 10 11)
j=0r=0old_free=[6 7 10 11]rows=zeros(length(old_free),1);for i=1:length(e) % i
for jj=1:length(old_free) [row,~]=find(nodes(i,1)==old_nodes(old_free(jj),1) & nodes(i,2)==old_nodes(old_free(jj),2)) if isempty(row) r=r+1 else j=j+1 rows(j)=row; end endend
Essentially what i would like is a column with the indices of the coordinates from nodes which match the indices of the entries for old_nodes, which will all be unique pairs:
e.g.
1 45 811 3
If anyone can be of help, I'd greatly appreciate it.
Best Answer