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:
Counting consecutive 1s in a matrix

Subject: Counting consecutive 1s in a matrix

From: Craig

Date: 1 Mar, 2011 15:07:20

Message: 1 of 1

This is an example of the matrix i have (mine is much bigger)
V =

     1 1 0
     1 1 0
     1 1 0
     1 2 0
     1 2 0
     1 3 0
     1 4 0
     2 1 0
     2 2 1
     2 3 1
     2 4 1
     2 5 1
     2 6 1
     2 6 1
     3 1 0
     3 2 1
     3 2 0
     3 3 0
     3 4 0
     3 4 0
     3 4 1
     3 4 1
     3 4 1
     3 4 1
     3 4 0
     3 4 0
     3 4 1
I need to find the longest chain of consecutive 1's in the third column, but each chain must have the same numbers in the 1st and 2nd column.
 i.e. in this example the longest chain of 1's is 4, located where the first and second coulmn are 3 & 4 respectively.
I dont mind if its seperated into lots of smaller matrices i just need a full method please

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