椭圆的拟合优度用什么指标评价啊。

我用如下的程序进行了椭圆拟合,如何评价其拟合效果啊?在网上查的用R^2,这个R^2事如何计算的呢?x=【-0.067624357,-0.003359844,0.063037813,0.089413159,0.059020652,-0.008843696,-0.071093237,-0.088206129
-0.049317504,0.020882494,0.077824328,0.085355985,0.038695664,-0.032532291,-0.083105699,-0.080915821,-0.027352997
0.043576072,0.086838968,0.074968348,0.015500796,-0.053808114-0.088954591】
y=【0.268839461 ,1.714580918,2.071745728,1.113572199,-0.551601318,-1.866566626,-1.996460517,-0.858814177,0.824087886,1.98378173,1.883985025,0.588058071,-1.081223256,-2.064042734,-1.736414456,-0.306347556,1.318217482
2.105854527,1.556497772,0.018930366,-1.530655811,-2.108438235,-1.347586479】
XY=[x,y];
F=@(p,XY)p(1)*XY(:,1).^2+p(2)*XY(:,1).*XY(:,2)+p(3)*XY(:,2).^2+p(4)*XY(:,1)+p(5)*XY (:,2)+p(6);%椭圆一般方程
p0=[1 1 1 1 1 1];
p=nlinfit(XY, zeros(size(XY,1),1), F, p0);
plot(XY(:,1), XY(:,2), 'ro');
hold on;
xmin=min(XY(:, 1));
xmax=max(XY(:, 1));
ymin=min(XY(:, 2));
ymax=max(XY(:, 2));
ezplot(@(x,y)F(p,[x,y]), [-1+xmin,1+xmax,-1+ymin,1+ymax]);

 Réponse acceptée

xanolep
xanolep le 20 Nov 2022

0 votes

clear,clc
x=[...];%xdata
y=[...];%ydata
fx1=@(b,x)b(1)*x+sqrt(b(2)+b(3)*x.^2);
fx2=@(b,x)b(1)*x-sqrt(b(2)+b(3)*x.^2);
b=[13.05887549, 3.096538149, -386.9576467];
y1=fx1(b,x);y2=fx2(b,x);
n=length(y);
for i=1:n
if abs(y(i)-y2(i))<=abs(y(i)-y1(i))
y1(i)=y2(i);
end
end
SSy=var(y)*(n-1),%total sum of squares
RSS=(y-y1)'*(y-y1),%residual sum of squares
Rsquare=(SSy-RSS)/SSy; %R-square
vpa(Rsquare,10)
MSe=RSS/(n-3-1),%
RMSe=sqrt(MSe)
figure(1),clf
plot(x,y,'go','markersize',10,'markerfacecolor','k')
hold on
x1=linspace(min(x)-.001,max(x)+.001,350);
y1=fx1(b,x1);y2=fx2(b,x1);
plot(x1,y1,'r-','linewidth',3)
plot(x1,y2,'r-','linewidth',3)
axis tight

Plus de réponses (0)

Catégories

En savoir plus sur 变量 dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!