0
votes

I have 2 matrices: Parent matrix (19564 X 5) and a child matrix (3913 X 3) (sub-matrix of parent). The 3 cols in child matrix and 1st 3 cols in parent matrix are x,y and z - coordinates.

Parent= [x,y,z,A,B]
Child= [x,y,z]

I need to extract 4th and 5th column (A and B) from parent matrix corresponding to x,y,z coordinates in child matrix.

I tried using ismember function in MATLAB, but it performs a col-wise search and I don't get the desired output.

As output, I need a 3913 X 5 matrix whose 1st 3 cols are exactly same as the child matrix and then 2 additional cols (A and B) from parent matrix.

1

1 Answers

1
votes

You need ismember with the rows flag to match xyz coordinates in both matrices and then use the result of it to extract the required rows from the Parent matrix.

out = Parent(ismember(Parent(:,1:3), Child, 'rows'), :);