MATLAB MATLAB: Plotting a Circle from Unordered Data Points

  • Thread starter Thread starter Niles
  • Start date Start date
  • Tags Tags
    Matlab Plotting
Click For Summary
To plot unordered data points that trace a circle in MATLAB, it's essential to sort the points based on their spatial relationships. A recommended approach is to use the convex hull technique, specifically the Graham-Scan algorithm, which organizes points in a way that outlines the convex shape. This method can be applied in 2D to create an ordered list of points, facilitating a proper circular plot. Additionally, exploring MATLAB's computational geometry libraries may provide existing implementations of 2D convex hull algorithms. Another suggestion is to convert the points to polar coordinates to sort them by angle, ensuring they are plotted in the correct order. For a visual representation, consider plotting the points without connecting them, resulting in a dotted circle effect.
Niles
Messages
1,834
Reaction score
0
Hi

I have a dataset which traces out a circle. The issue is that the data points are not ordered, so if I plot the set and make lines between adjacent (= "adjacent" in the sense that they are next to each other in the dataset) data points, then the plot does not look like a circle.

Is there a way to plot data in MatLAB such that the points closest to each other get marked up?


Niles.
 
Physics news on Phys.org
Hey Niles.

Have you considered a routine that sorts the points based on their distance and relationship to other points?

There is a technique that would work that sorts points for a convex polytype and this technique is called the convex hull: in 2D, the calculation is simplified using what is known as the Graham-Scan algorithm.

If you have any set of points that describe the outline of a convex polytype (in n-dimensions), then this algorithm (if implemented in n-dimensions) will give you an oriented list of objects. For 2D, you can an ordered list of points, for 3D an ordered list of planes (triangles) and so on.

See if someone has written a 2D convex hull algorithm for MATLAB, and check the computational geometry libraries in MATLAB, because convex-hull algorithms are basically computational geometry techniques, often used in scientific and game engine applications (as well as in rendering applications of any kind).
 
if your points are in x,y form then perhaps by converting to polar to get the theta angle then use it as a key to sort your data in ascending theta order before plotting.

You could plot without connecting a line between your points so that you get a dotted circle.
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
3K
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K