Thread Subject: How to find out the vector that inside them there are two elements

Subject: How to find out the vector that inside them there are two elements

From: narrow 12

Date: 20 Nov, 2009 10:25:39

Message: 1 of 2

Dear all,

I have a matrix as below:
a b c d e f g h i j
1 0 1 0 0 0 0 1 0 1
1 0 0 0 1 1 1 0 0 0
0 0 0 1 0 0 0 1 0 1
0 1 1 1 1 0 0 0 0 1
0 1 1 0 1 0 0 1 1 0
0 1 0 1 0 1 1 0 1 0
1 0 0 0 0 1 1 0 1 0

I know how to search the exact same vetor, but if I want to find out
the vectors that have 2 elements the same, for example, b,c and e have
the 2 elements are the same. f,g,and i have 2 elements are the same,
i, b have 2 elements are the same. How can I make use of row index or
column index to find out which vectors are having the same 2 elements.
Or is there any other way to solve the problem?

Thanks in advance
Narrow

Subject: How to find out the vector that inside them there are two elements

From: Jan Simon

Date: 20 Nov, 2009 11:21:11

Message: 2 of 2

Dear narrow!

> I have a matrix as below:
> a b c d e f g h i j
> 1 0 1 0 0 0 0 1 0 1
> 1 0 0 0 1 1 1 0 0 0
> 0 0 0 1 0 0 0 1 0 1
> 0 1 1 1 1 0 0 0 0 1
> 0 1 1 0 1 0 0 1 1 0
> 0 1 0 1 0 1 1 0 1 0
> 1 0 0 0 0 1 1 0 1 0
>
> I know how to search the exact same vetor, but if I want to find out
> the vectors that have 2 elements the same, for example, b,c and e have
> the 2 elements are the same. f,g,and i have 2 elements are the same,
> i, b have 2 elements are the same. How can I make use of row index or
> column index to find out which vectors are having the same 2 elements.

Are 'a', 'b', ... part of the matrix?!
b, c, e have 4 common elements, not 2. Or are the zeros no "elements". Please define the problem more precisely.

If you search ones at the same positions in 2 vectors, use AND:
  b = [0,0,0,1,1,1,0]
  c = [1,0,0,1,1,0,0]
  and(b,c)
==> [0,0,0,1,1,0,0]
And to get the number of ones in the answer, just use SUM.

Good luck, Jan

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