How to fit a square and find the center point?

7 ビュー (過去 30 日間)
aneps
aneps 2014 年 1 月 14 日
コメント済み: Matt J 2014 年 1 月 14 日
I have a data plot look like in the picture:
I want to fit a square box enclosing maximum number of points and find the center of the box. You can see in the picture, the top and the right side seems to be the edge of the square. So the fit can assume the top and the right side as the two edges. How can I do this?

採用された回答

Matt J
Matt J 2014 年 1 月 14 日
編集済み: Matt J 2014 年 1 月 14 日
If your points are the rows of a matrix P, then
lowerleftCorner=min(P);
upperrightCorner=max(P);
center = lowerleftCorner/2 + upperrightCorner/2;
This will give you the corners of the tightest, non-rotated rectangle around the points. If you really do want a square and not a rectangle, you can enlarge one of the sides of the rectangle.
  1 件のコメント
Matt J
Matt J 2014 年 1 月 14 日
If you need a rotated rectangle, then this FEX file seems to do that

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by