How to determine connectivity with binary numbers?

3 visualizaciones (últimos 30 días)
David
David el 25 de Abr. de 2012
I am looking to optimize the material properties of a composite matrix made up of fibers and a matrix. One of the constraints are that the fibers must be connected. For example the following matrix shows fibers all connected to each other,
[1 1 2 2 2; 1 1 1 2 2; 2 1 1 1 2; 2 1 1 2 2; 2 2 2 2 2];
Where 1 is a fiber, and 2 is the matrix(epoxy) material.
Here is an example of an incorrect matrix that does not meet the constraints.
[1 2 2 2 2; 2 2 1 2 2; 2 2 2 2 1; 1 1 2 2 2; 2 2 2 2 2]; What function would be most useful to make a constraint, assuring the 1's are connected?
I tried to use the function bwlabel, but it seems to only work for "traditional" binary 0 and 1. I need to keep the numbers 1 and 2 for my problem. Is there a way to do this still?

Respuestas (1)

Geoff
Geoff el 25 de Abr. de 2012
Yeah.
A = [1 2 2 2 2; 2 2 1 2 2; 2 2 2 2 1; 1 1 2 2 2; 2 2 2 2 2];
B = ~logical( A - 1 );
Now do your tests with B, leaving A unchanged.
  2 comentarios
Walter Roberson
Walter Roberson el 26 de Abr. de 2012
You might find
B = (A == 1);
easier to read.
David
David el 26 de Abr. de 2012
Thank you Geoff.

Iniciar sesión para comentar.

Categorías

Más información sobre Discrete Math en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by