Thread Subject: Find repeating data in 3D array

Subject: Find repeating data in 3D array

From: Wrighty43 Wright

Date: 19 Nov, 2009 17:42:06

Message: 1 of 2

Hopefully someone can suggest a very simple solution that i have overlooked.
I have a 3d array with values as follows:

ans(:,:,1) =
   19.0000 0
   17.0000 29.9666
   18.0000 31.5595
   24.0000 47.0532
   44.0000 49.0306
ans(:,:,2) =
   19.0000 0
   18.0000 3.3166
   42.0000 8.2462
   17.0000 8.3666
   45.0000 9.1104
ans(:,:,3) =
   19.0000 0
   18.0000 12.4499
   42.0000 14.8661
   45.0000 16.3707
   17.0000 16.6132

I need to find out if any numbers in the first coloumn are repeated in other coloumns, for example 18,17,42 are all repeated. So i would like something that would tell me this in the form of a position (so i can extract the corresponding data in the second coloumn)....
AND to make it more complex i need to kno if the number is repeated twice or three times (so 18,17 are both repeated 3 times, and 42 twice).

Hope someone can help.
Cheers

(Just to give some context to this problem, the left hand coloumn is image number, and the right one is the L2Norm value. of the image compared to image 19 using 3 different MPEG-7 Image descriptions, and is effectively a CBIR system)

Subject: Find repeating data in 3D array

From: dpb

Date: 19 Nov, 2009 18:33:41

Message: 2 of 2

Wrighty43 Wright wrote:
> Hopefully someone can suggest a very simple solution that i
> have overlooked.
> I have a 3d array with values as follows: >
> ans(:,:,1) =
> 19.0000 0
> 17.0000 29.9666
> 18.0000 31.5595
...
> 45.0000 9.1104
> ans(:,:,3) =
> 19.0000 0
> 18.0000 12.4499
...
>
> I need to find out if any numbers in the first coloumn are repeated
> in other coloumns, for example 18,17,42 are all repeated. So i
> would like something that would tell me this in the form of a position
> (so i can extract the corresponding data in the second coloumn)....
> AND to make it more complex i need to kno if the number is repeated
> twice or three times (so 18,17 are both repeated 3 times, and 42
> twice)....

 >> m=unique(b(:,1,1));
 >> ismember(b(:,1,2:3),m)
ans(:,:,1) =
      1
      1
      0
      1
      0
ans(:,:,2) =
      1
      1
      0
      0
      1
 >>

--

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com