Identify a closed curve?

4 ビュー (過去 30 日間)
Jannen Paiva
Jannen Paiva 2015 年 3 月 23 日
コメント済み: Image Analyst 2015 年 3 月 23 日
If I plot a graph, is there a way for Matlab to check if its a closed curve?

回答 (2 件)

Image Analyst
Image Analyst 2015 年 3 月 23 日
Try this
if x(1) == x(end) && y(1) == y(end)
% It's closed
else
% It's not closed
end
  2 件のコメント
Jannen Paiva
Jannen Paiva 2015 年 3 月 23 日
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 2015 年 3 月 23 日
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.

サインインしてコメントする。


John D'Errico
John D'Errico 2015 年 3 月 23 日
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.

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by