syms C1 C2 C3 x y;
c1=[2.0810;3.6763];c2=[1.7604;4.9588];
xc=2;%yc=4;
yc=(xc-c1(1))/(c2(1)-c1(1))*(c2(2)-c1(2))+c1(2);
f=C1*x^2+C2*x*y+C3*y^2-(2*C1*xc+C2*yc)*x-(2*C3*yc+C2*xc)*y+(C1*xc^2+C2*xc*yc+C3*yc^2-1);
y1=7.3080*x;
t1=subs(f,y,y1);
d1=coeffs(collect(vpa(t1)),x);
deta1=d1(2)^2-4*d1(3)*d1(1)
y2=0.9744*x;
t2=subs(f,y,y2);
d2=coeffs(collect(vpa(t2)),x);
deta2=d2(2)^2-4*d2(3)*d2(1)
y3=-0.6943*x+4.1660;
t3=subs(f,y,y3);
d3=coeffs(collect(vpa(t3)),x);
deta3=d3(2)^2-4*d3(3)*d3(1)
[C1,C2,C3]=solve(deta1,deta2,deta3)
为什么这样求出来的解是错误的,而如果把yc=4,就能求出正解,但是yc=(xc-c1(1))/(c2(1)-c1(1))*(c2(2)-c1(2))+c1(2)也是等于4的呀。

 Réponse acceptée

votatev
votatev le 25 Nov 2022

0 votes

计算机是有舍入误差的噢,鉴于的计算对数值是敏感的。如果计算方式都是一模一样的,并排除了程序存在问题的可能性,那么,就可以考虑存在由于舍入误差引入计算结果差异的可能性。

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox 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!