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:
find duplicate entries for each row

Subject: find duplicate entries for each row

From: Skirt Zhang

Date: 5 May, 2013 17:26:10

Message: 1 of 2

Dear All,

I have a n*2 matrix which is as below and consists of only 1, 2, 3 inside

idx=[
     2 2
     1 2
     3 2
     1 2
     1 3
     3 1
     2 2
     1 3
     2 2
     1 2
     3 1]
I would like to find for which row the entries are the same, e.g. 2==2 then store the row index and the number 2. Which function can help me to realize this?

Thanks

Subject: find duplicate entries for each row

From: reza

Date: 5 May, 2013 19:38:11

Message: 2 of 2

On Sunday, May 5, 2013 1:26:10 PM UTC-4, Skirt Zhang wrote:
> Dear All,
>
>
>
> I have a n*2 matrix which is as below and consists of only 1, 2, 3 inside
>
>
>
> idx=[
>
> 2 2
>
> 1 2
>
> 3 2
>
> 1 2
>
> 1 3
>
> 3 1
>
> 2 2
>
> 1 3
>
> 2 2
>
> 1 2
>
> 3 1]
>
> I would like to find for which row the entries are the same, e.g. 2==2 then store the row index and the number 2. Which function can help me to realize this?
>
>
>
> Thanks

row index of identical entries:

>> find(idx(:,1) == idx(:,2))

only works if matrix has 2 columns

/reza

Tags for 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