Polyshape: stop Connecting first and last points.

Hello all, How you doin? Can you please help me with an issue?
Problem:
I have many sets of Data (Like attached one), in two vectors that are produced seperetly by another script.
Now, I need to plot them, devide them between "Closed" and "Open" , Then search between "Closed" ones to see which one is the stable one.
I used "polyshape" like it:
load('Data');
a = polyshape(Data(:,1),Data(:,2),'Simplify',true);
b =regions(a);
plot(b)
the problem is that polyshape connects first and last point automaticlly (even when simplify is off). So all regions are closed now and finding stable region encounter with wrong answers.
Do you have any idea, about disabling this feature (to leave the plot as it is), Or any alternative command that works like "polyshape" and has ability to recognize regions with their boundry points?
Thanks a lot for your time.
----------------------------------------------------------------------------------------------------
Another Example:
how to find boundries of JUST closed area of this points? (Data2.m)
ee.JPG

5 Kommentare

Adam Danz
Adam Danz am 12 Nov. 2019
How are you categorizing closed and open?
For open 'shapes' ('lines' is probably better), how do you expect that they appear? Why not just apply polyshape() to the closed sets and use plot() for the open ones?
Hi,
I don't meant "how to plot (or show them). and above picture was just an example.
Exactly the problem is about how to categorize closed sets from open lines ( since "polyshape" connects first and last point, artificial closed areas have been created.)
Code's about to find closed sets, then search better one (for example which has stable points).
but i can't find closed regions at the first place :(
Adam Danz
Adam Danz am 12 Nov. 2019
Bearbeitet: Adam Danz am 12 Nov. 2019
I see.
I don't think this is an easy problem to solve. How do you define what is open and what is closed? Are these open?
I think there should be a definition of what it means to be "open" before proceeding.
Adam Danz
Adam Danz am 13 Nov. 2019
Armin Mashhadi's answer moved here as a comment.
Got it.
Adam Danz
Adam Danz am 13 Nov. 2019
@ Armin Mashhadi, if you'd like to share your solution, please add it as an answer. "got it" isn't an answer.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Stijn Haenen
Stijn Haenen am 12 Nov. 2019

0 Stimmen

Hi,
do you mean this?
load('Data');
a=polyshape(Data(:,1),Data(:,2));
b=regions(a);
area=[b(2,1).Vertices(:,1) b(2,1).Vertices(:,2)];
line=[b(3,1).Vertices(:,1) b(3,1).Vertices(:,2);b(1,1).Vertices(:,1) b(1,1).Vertices(:,2)];
shape_area=polyshape(area);
plot(regions(shape_area));
hold on
[c,d]=max(line(1:end-1,1)-line(2:end,1));
plot(line(d+1:end,1),line(d+1:end,2),'black');
plot(line(1:d-1,1),line(1:d-1,2),'black');

1 Kommentar

Hi,
I really appreciate your efford and spending time.
But no, that was not wat i meant.
The question is how to find that region2 is closed and others are not , automaticlly.
But you assumed that region2 is closed then drew using its vertices.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 12 Nov. 2019

Kommentiert:

am 13 Nov. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by