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

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)

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

In the right (green*) is the correct curve but after using boundary() function I am getting the left curve. You can clearly see that the bottom bally is very flat. This is where data has changed. I want the output (array data) should not change but only I need to arrange those segmenter curves in a continuous fashon.
another output error
Output should be right curve and what I am getting is left curve so many missing points.
Is there any way that the right curves can be converted into x, y coordinates in an order(clockwise or anticlockwise) and they must be continuous.
The data is attached in an excel sheet form,and the first data is for the curve shown below.

Sign in to comment.

Categories

Products

Release

R2020a

Asked:

on 6 Feb 2021

Commented:

on 15 Feb 2021

Community Treasure Hunt

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

Start Hunting!