MATLAB: Plotting a Circle from Unordered Data Points

In summary, the conversation discusses the issue of plotting a circle from a dataset with unordered data points. The technique of using a convex hull algorithm to sort the points based on their distance and relationship to each other is suggested. This algorithm can give an oriented list of objects, such as an ordered list of points for 2D data. The option of converting the data to polar form and sorting by theta angle is also mentioned. Another suggestion is to plot the points without connecting them with a line, resulting in a dotted circle.
  • #1
Niles
1,866
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
  • #2
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).
 
  • #3
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.
 

1. How do I plot a circle from unordered data points in MATLAB?

To plot a circle from unordered data points in MATLAB, you can use the "circle" function. This function takes in the center coordinates and radius of the circle, as well as the number of points you want to plot on the circle. It then uses these points to create a smooth circle.

2. Can I plot a circle using only x and y coordinates?

Yes, the "circle" function in MATLAB allows you to specify the center coordinates of the circle using only x and y coordinates. You can also specify the radius of the circle using the same coordinates.

3. How can I change the color and style of the circle plot?

To change the color and style of the circle plot, you can use the "plot" function after calling the "circle" function. The "plot" function allows you to specify the color, line style, and marker style of the plot.

4. Is it possible to plot multiple circles from different sets of unordered data points?

Yes, you can plot multiple circles from different sets of unordered data points in MATLAB. Simply call the "circle" function multiple times with different center coordinates and radii, and use the "hold on" command to plot them all on the same figure.

5. Can I label the points on the circle plot?

Yes, you can label the points on the circle plot by using the "text" function in MATLAB. You can specify the coordinates of the point you want to label and the text you want to display, and the "text" function will add a label to the plot.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
737
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
Back
Top