Extracting rows with specific condition in MATLAB
5 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Azzi Abdelmalek
on 18 Mar 2013
Edited: Azzi Abdelmalek
on 18 Mar 2013
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 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!