How to determine connectivity with binary numbers?
조회 수: 2 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Discrete Math에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!