Extracting rows with specific condition in MATLAB

6 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 18 Mar 2013
Modificato: Azzi Abdelmalek il 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'),:)

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by