Identify a closed curve?

4 visualizaciones (últimos 30 días)
Jannen Paiva
Jannen Paiva el 23 de Mzo. de 2015
Comentada: Image Analyst el 23 de Mzo. de 2015
If I plot a graph, is there a way for Matlab to check if its a closed curve?

Respuestas (2)

Image Analyst
Image Analyst el 23 de Mzo. de 2015
Try this
if x(1) == x(end) && y(1) == y(end)
% It's closed
else
% It's not closed
end
  2 comentarios
Jannen Paiva
Jannen Paiva el 23 de Mzo. de 2015
sorry, I don't know if this kind is called a closed curve http://postimg.org/image/yn339fvc1/
but that's the kind, with the figure 8-ish shape, that I want to check for
Image Analyst
Image Analyst el 23 de Mzo. de 2015
I don't care if it crosses itself or not. If it's closed, then the last point will be the same as the first point. If not it's definitely not closed. Just think about it. If I draw a circle around a clock and start at 12 at the top and go around clockwise and end at 11, it's not closed. If I have a bunch of points tracing out a figure 8, then it's not closed unless the last point can be drawn connecting it to the first point. "Close" to the first point is not good enough! So I don't really understand your comment. By the way, it looks like what you have in your picture is a closed curve.

Iniciar sesión para comentar.


John D'Errico
John D'Errico el 23 de Mzo. de 2015
Once you plot it, you have a picture. Far easier is to do any analysis BEFORE you plot it. Asking to do so afterwards is an act of closing the barn door after the horse has escaped. Then you must either extract the data from the figure to do your analysis, or you must treat it as an image.
So if you are going to extract the data from the figure, just do that analysis then, BEFORE the plot ever gets generated.
Image Analyst has already shown how to do that test, unless your curve is more complex than that. For example, does it self-intersect? Only you can decide if that represents a closed curve.

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by