MATLAB: Match row and column MATLABrow I have one matrix a=1 3 02 5 03 7 04 8 05 10 0 and another is b=5 103 7 I want to do find(a(:,1)=b(:,1) & a(:,2)==b(:,2) so that 5 10 03 7 0 Best Answer You can use ismember to generate the logical indices. In the same order as a:>> idx = ismember(a(:,1:2),b,'rows');>> a(idx,:)ans = 3 7 0 5 10 0Or in the same order as b:>> [~,idx] = ismember(b,a(:,1:2),'rows');>> a(idx,:)ans = 5 10 0 3 7 0 Related SolutionsMATLAB: Sort matrix to get the row and column position of sorted matrix [~,idx] = sort(M(:), 'descend');idx(M(:)==0) = [];[row, col] = ind2sub(size(M), idx);indexes = [row col];Result:indexes = 4 5 1 2 1 3 1 4 2 6 5 7 4 7 3 4 1 5 ....... MATLAB: Deleting rows of matrix from the rows of other matrix with different dimension The simplest solution is to use ismember with its 'rows' option:idx = ismember(A(:,1:2),B,'rows');A(idx,:) = [] Related QuestionRemove repeated rows to produce two new matricesCopy data for one table to anotherSubtract a row from a matrixFinding a row in matrixQuestion of a vlookup equivalent in matlabDeleting rows with identical values in determined columns of two matrices.
Best Answer