poster
2019-12-10, 20:48
两个矩阵A和B:
A = [1 2 3 9 7 5 4 9 4 1 4 7] B = [1 2 3 1 4 7] 矩阵B的所有行都是矩阵A的成员。我希望从A中删除A和B的公共行,而不进行排序。
我尝试过setdiff(),但这对输出进行排序。
对于我的特定问题(蛋白质结构中的原子坐标),保持行的有序完整性很重要。
回答:
使用ISMEMBER (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ismember.html) :
%# find rows in A that are also in B commonRows = ismember(A,B,'rows'); %# remove those rows A(commonRows,:) = [];
更多&回答... (https://stackoverflow.com/questions/3467670)
A = [1 2 3 9 7 5 4 9 4 1 4 7] B = [1 2 3 1 4 7] 矩阵B的所有行都是矩阵A的成员。我希望从A中删除A和B的公共行,而不进行排序。
我尝试过setdiff(),但这对输出进行排序。
对于我的特定问题(蛋白质结构中的原子坐标),保持行的有序完整性很重要。
回答:
使用ISMEMBER (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ismember.html) :
%# find rows in A that are also in B commonRows = ismember(A,B,'rows'); %# remove those rows A(commonRows,:) = [];
更多&回答... (https://stackoverflow.com/questions/3467670)