MATLAB: Plotting a Circle from Unordered Data Points

  • Context: MATLAB 
  • Thread starter Thread starter Niles
  • Start date Start date
  • Tags Tags
    Matlab Plotting
Click For Summary
SUMMARY

This discussion focuses on plotting a circle from unordered data points in MATLAB. The suggested solution involves using the Graham-Scan algorithm to implement a convex hull technique, which organizes the points based on their spatial relationships. By sorting the points in polar coordinates according to their theta angles, users can achieve a proper circular representation. Additionally, plotting without connecting lines can provide a dotted circle visualization.

PREREQUISITES
  • Understanding of MATLAB programming
  • Familiarity with convex hull algorithms
  • Knowledge of polar coordinates and theta angles
  • Basic concepts of computational geometry
NEXT STEPS
  • Research the implementation of the Graham-Scan algorithm in MATLAB
  • Explore MATLAB's computational geometry libraries for convex hull functions
  • Learn about polar coordinate transformations in MATLAB
  • Investigate techniques for plotting data without connecting lines in MATLAB
USEFUL FOR

Data scientists, MATLAB users, and anyone interested in visualizing unordered datasets in a geometrically accurate manner.

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
4K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K