Identify a closed curve?

4 vues (au cours des 30 derniers jours)
Jannen Paiva
Jannen Paiva le 23 Mar 2015
Commenté : Image Analyst le 23 Mar 2015
If I plot a graph, is there a way for Matlab to check if its a closed curve?

Réponses (2)

Image Analyst
Image Analyst le 23 Mar 2015
Try this
if x(1) == x(end) && y(1) == y(end)
% It's closed
else
% It's not closed
end
  2 commentaires
Jannen Paiva
Jannen Paiva le 23 Mar 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 le 23 Mar 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.

Connectez-vous pour commenter.


John D'Errico
John D'Errico le 23 Mar 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.

Catégories

En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by