MATLAB: Plotting help

1. Jul 30, 2012

Niles

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 eachother 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 eachother get marked up?

Best,
Niles.

2. Jul 30, 2012

chiro

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. Jul 30, 2012

Staff: Mentor

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.