Extracting rows with specific condition in MATLAB
1 次查看(过去 30 天)
显示 更早的评论
Hi, i have a problem. I got two matric dimension mx3 and nx3. For example:
A=[2,2345,1; 2,2344,0; 4, 2345,56 ; 4,2000,1; 2,2346,22; 4,2111,1]
B=[2,2346,22; 2,2344,0; 4, 2314,56 ; 4,2111,1]
Ok, here are two matrix. What I want to do is to look first and second row and find same elements and on basis of this extract matrix C which will contain all rows that dont fit condition.
Example:
2,2346 in A fit 2,2346 from B
2,2345 in A and its not in B. That means the whole row goes to C 2,2345,1
And so on...I tried to this with setxor, but problem is that i look just second column.. Thank you for your help.
0 个评论
采纳的回答
Azzi Abdelmalek
2013-3-18
编辑:Azzi Abdelmalek
2013-3-18
A=[2,2345,1; 2,2344,0; 4, 2345,56 ; 4,2000,1; 2,2346,22; 4,2111,1]
B=[2,2346,22; 2,2344,0; 4, 2314,56 ; 4,2111,1]
C=A(~ismember(A(:,1:2),B(:,1:2),'rows'),:)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!