Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Finding Matrix in a Matrix row wise

Subject: Finding Matrix in a Matrix row wise

From: Ravi Shekhar

Date: 25 Feb, 2012 17:46:45

Message: 1 of 3

Hi,

 Suppose I have 2 matrix,

 A = [ 1 2;
       3 4;
       11 2];
& B = [ 1 2;
        13 4;
        1 2;
        3 4];
I want to find which al rows are not present in B. (in given case 3).
Also which all rows are present in which index (i.e [1 2] at 1 & 2 and [3 4] at 4)

 In my case B is large matrix 10M X 8 and is of size 500 X 8.

 What is efficient way of doing this.

Subject: Finding Matrix in a Matrix row wise

From: dpb

Date: 25 Feb, 2012 18:18:52

Message: 2 of 3

On 2/25/2012 11:46 AM, Ravi Shekhar wrote:
> Hi,
>
> Suppose I have 2 matrix,
>
> A = [ 1 2;
> 3 4;
> 11 2];
> & B = [ 1 2;
> 13 4;
> 1 2;
> 3 4];
> I want to find which al rows are not present in B. (in given case 3).

idx = find(~ismember(A,B,'rows');

> Also which all rows are present in which index (i.e [1 2] at 1& 2 and [3 4] at 4)
>
> In my case B is large matrix 10M X 8 and is of size 500 X 8.
>
> What is efficient way of doing this.

Should be hint enough in first for the second... :)

doc ismember % and friends

--

Subject: Finding Matrix in a Matrix row wise

From: Matt J

Date: 25 Feb, 2012 19:52:17

Message: 3 of 3

dpb <none@non.net> wrote in message <jib8md$4m0$1@speranza.aioe.org>...
>
> > I want to find which al rows are not present in B. (in given case 3).
>
> idx = find(~ismember(A,B,'rows');
====

or

 [~,idx]=setdiff(A,B,'rows');

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us