怎么用matlab拟合出椭圆方程
x=1036,y=856;x=1064,y=586;x=880,y=337;怎么拟合出椭圆的方程 展开
首先要下一个拟合工具 (在附件中),解压安装
x=[1132,350,222,334,890,1036,1064,880];
y =[574,419,828,1024,1034,856,586,337];
XY=[x;y]';
A = EllipseDirectFit(XY);
% A = [a b c d e f]
% ax^2 + bxy + cy^2 + dx + ey + f = 0
hold on
%Convert the A to str
a = num2str(A(1));
b = num2str(A(2));
c = num2str(A(3));
d = num2str(A(4));
e = num2str(A(5));
f = num2str(A(6));
%Equation
eqt= ['(',a, ')*x^2 + (',b,')*x*y + (',c,')*y^2 + (',d,')*x+ (',e,')*y + (',f,')'];
xmin=0.7*min(XY(:,1));
xmax=1.3*max(XY(:,2));
ezplot(eqt,[xmin,xmax])
scatter(XY(:,1),XY(:,2),'r')
hold off