How to join random curve segments to make a continuous entity from 2D array data
Show older comments

Out of such kind of data I need to know a general method to plot them as shown in figure below (a complete single curve with arranged coordinates in 1D array x, y, like below)
Output :
If it is counterclockwise or use fliplr() to flip the data to make clockwise.

Line2 or any curve name means all arranged 72 points for Line 2 and so on.
This should be the output of arranged data,

Consider this information :
They are end to end connected and can be clockwise or counter-clockwise in rotation (user choice). They may have different starting points (see polyline 2 data reverse in rotation) so we may need to flip that data to match the final point (from previous curve) and first point (from the current curve).
The data is always 2D, equally spaced (72 - columns) for x and y cartesian coordinates. First row can be any curve so take the first row as your starting point.
I tried with polar coordinates to arrange them but there are some problems when the curve is too close to each other, they are not connecting correctly. If you can implement a polar coordinates method then that can also help. In that case you may need to reduce the step size to compare.
Answers (1)
KSSV
on 10 Feb 2021
I assume you have multiple data's of lines and/or curves. I assume that each data (xi, yi) is a column array. First merge them into a single data (x,y).
idx = boundary(x,y) ;
x = x(idx) ;
y = y(idx) ;
plot(x,y)
3 Comments
Dharmendra Patel
on 14 Feb 2021
KSSV
on 14 Feb 2021
Attach your data...
Dharmendra Patel
on 15 Feb 2021
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

