• 大小: 3KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-12
  • 语言: Matlab
  • 标签:

资源简介

通过离散点拟合出椭圆,得到椭圆参数,并在matlab里直接作图,直接使用,方便,经测试

资源截图

代码片段和文件信息

function [varargout]=ellipsefit(xy)
%ELLIPSEFIT Stable Direct Least Squares Ellipse Fit to Data.
% [XcYcABPhiP]=ELLIPSEFIT(XY) finds the least squares ellipse that
% best fits the data in X and Y. X and Y must have at least 5 data points.
% Xc and Yc are the x- and y-axis center of the ellipse respectively.
% A and B are the major and minor axis of the ellipse respectively.
% Phi is the radian angle of the major axis with respect to the x-axis.
% P is a vector containing the general conic parameters of the ellipse.
% The conic representation of the ellipse is given by:
%
% P(1)*x^2 + P(2)*x*y + P(3)*y^2 + P(4)*x + P(5)*y + P(6) = 0
%
% S=ELLIPSEFIT(XY) returns the output data in a structure with field names
% equal to the variable names given above e.g. S.Xc S.Yc S.A S.B
% S.Phi and S.P
%
% Reference: R. Halif and J. Flusser “Numerically Stable Direct Least
% Squares FItting of Ellipses“ Department of Software Engineering Charles
% University Czech Republic 2000.

% Conversion from conic to conventional ellipse equation inspired by
% fit_ellipse.m on MATLAB Central

% D.C. Hanselman University of Maine Orono ME 04469
% Mastering MATLAB 7
% 2005-02-28
% Rotation angle fixed 2005-08-09

%--------------------------------------------------------------------------
x=x(:); % convert data to column vectors
y=y(:);
if numel(x)~=numel(y) || numel(x)<5
   error(‘X and Y Must be the Same Length and Contain at Least 5 Values.‘)

评论

共有 条评论

相关资源