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:
Frequently occurring sets of numbers per row in a matrix

Subject: Frequently occurring sets of numbers per row in a matrix

From: Chantal

Date: 22 Oct, 2013 21:06:08

Message: 1 of 2

I am looking to find sets of values within a row which tend to occur together over all rows of a matrix.
For example:
MAT = [ 1 2 3 0; 1 2 4 0; 5 6 7 0; 5 6 7 9; 1 2 8 0];
where 0 is simply a placeholder to maintain the dimensions of the matrix. By eye, one can see that 1 and 2 tend to occur together and 5, 6 and 7 tend to occur together within a row.
One thought is to simply count how many times each individual value appears in a row with another individual value (nchoosek(9,2)). In this example it would provide a 9x9 matrix of counts with the greatest values along the diagonal, but this doesn't really give a great picture of which sets (perhaps > 2 values) occur most often. Any advice would be greatly appreciated- thank you.
As a note, I have tried using unique and ismember, but the results haven't proved very valuable.

Subject: Frequently occurring sets of numbers per row in a matrix

From: Steven Lord

Date: 23 Oct, 2013 14:08:02

Message: 2 of 2


"Chantal " <cmm384@gmail.com> wrote in message
news:l46pc0$hqj$1@newscl01ah.mathworks.com...
> I am looking to find sets of values within a row which tend to occur
> together over all rows of a matrix.
> For example:
> MAT = [ 1 2 3 0; 1 2 4 0; 5 6 7 0; 5 6 7 9; 1 2 8 0]; where 0 is simply a
> placeholder to maintain the dimensions of the matrix. By eye, one can see
> that 1 and 2 tend to occur together and 5, 6 and 7 tend to occur together
> within a row.

Everywhere that 3 appears in this matrix it appears with 1 and 2. What are
your criteria by which you decide that 1 and 2 "tend to occur together" and
1 and 3 do not?

It sounds like you're looking for cliques in the graph where two vertices
are connected by an edge if they appear in the same row of this matrix.

http://en.wikipedia.org/wiki/Clique_%28graph_theory%29

Some of the references on that page may lead you to algorithms that you
could implement on the adjacency matrix form of this graph.

*snip*

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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