How do I delete the intersection of sets A and B from A without sorting in MATLAB?

前端 未结 2 1759
眼角桃花
眼角桃花 2021-01-18 10:44

Two matrices, A and B:

A = [1 2 3
     9 7 5
     4 9 4
     1 4 7]

B = [1 2 3
     1 4 7]

All rows of matrix B are members of matrix A. I

2条回答
  •  伪装坚强ぢ
    2021-01-18 11:35

    Use ISMEMBER:

    %# find rows in A that are also in B
    commonRows = ismember(A,B,'rows');
    
    %# remove those rows
    A(commonRows,:) = [];
    

提交回复
热议问题