Hi,
I'm trying to calculate stable region automatically by Matlab. As shown in picture, Boundries are driven (as 2 vector of x,y) and split the plate into several closed areas.
Every closed area has a specific number and Somehow these numbers are related to each other.
I have to :
  1. Define very closed area
  2. Attribute an number (for example 2) for each Area
at last The area with least number is The stable region.
I have coordinates of intersections (Red Points), I was thinking about using these points and "inpolygon" command to find a point within The area and attribute the number to that point instead of whole surface. But Vertex Points are not connected Respectively (e.g 3th, 4th and 8th are making an area) and that does not work for me.
Could you please help me out of this ?

 채택된 답변

Bruno Luong
Bruno Luong 2019년 9월 9일
편집: Bruno Luong 2019년 9월 9일

0 개 추천

You might checkout POLYSHAPE, that can give you the regions
P = polyshape(rand(10,2));
R = regions(P);
close all
plot(R);
for k=1:length(R)
[x,y]=R(k).centroid;
text(x,y,num2str(k));
end
polyshape.png

댓글 수: 3

Armin Mashhadi
Armin Mashhadi 2019년 9월 9일
편집: Armin Mashhadi 2019년 9월 9일
Thank you very very much,
It probebly solved my problem, exepct that holes!
It would not connect all verteces so some empty areas will be created !
Even "ishole" says no hole is in the plot :(
Bruno Luong
Bruno Luong 2019년 9월 9일
편집: Bruno Luong 2019년 9월 9일
The white part is the complement of P: meaning the surounding rectangle substracted P. Checkout boolean operation of polyshape to get that complement.
Repeat the same process wuth the complement.
Box = polyshape([0 0;
1 0;
1 1;
0 1;
0 0]);
P = polyshape(rand(10,2));
Q = subtract(Box, P);
R1 = regions(P);
R2 = regions(Q);
R = [R1; R2];
close all
plot(R);
for k=1:length(R)
[x,y]=R(k).centroid;
text(x,y,num2str(k));
end
Split.png
Armin Mashhadi
Armin Mashhadi 2019년 9월 10일
Thanks a lot, that worked for me ..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Polygonal Shapes에 대해 자세히 알아보기

태그

질문:

2019년 9월 9일

댓글:

2019년 9월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by