How to determine connectivity with binary numbers?

5 ビュー (過去 30 日間)
David
David 2012 年 4 月 25 日
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?

回答 (1 件)

Geoff
Geoff 2012 年 4 月 25 日
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 件のコメント
Walter Roberson
Walter Roberson 2012 年 4 月 26 日
You might find
B = (A == 1);
easier to read.
David
David 2012 年 4 月 26 日
Thank you Geoff.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDiscrete Math についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by