matlab2014版函数,matlab - 函数'求解',求解函数的多项式系统,在Matlab 2011和Matlab 2014中返回不同的答案 - 堆栈内存溢出...

我有一个多项式函数系统来解决。

我在Matlab 2011和Matlab 2014中尝试过它。但Matlab 2011的答案是正确的,Matlab 2014的答案是错误的。

我发现Matlab 2014关于求解多项式方程组的答案常常是错误的,但Matlab 2011总是正确的。

我不是为什么? 如果我想使用Matlab 2014或更新版本的Matlab,我该怎么做才能得到正确的答案?

以下是我的主要代码部分。

syms U,V是unknows。 并且所有其他变量都是已知值或已经计算出的值。

我将已知变量设置为:

phais = zeros(1,3);

phais(1) = 2*pi*0.413;

phais(2) = 2*pi*0.744;

phais(3) = -phais(1)-phais(2);

h = 0.7;

r = 1.2;

theta = 2*pi*0.54;

optical_center = [cos(theta)*r , sin(theta)*r, h];

phai1 = phais(1);

phai2 = phais(2);

phai3 = phais(3);

r = 1;

a = [r*cos(phai1), r*sin(phai1), 0];

b = [r*cos(phai2), r*sin(phai2), 0];

c = [r*cos(phai3), r*sin(phai3), 0];

%calculate the distance between the control points

d3 = sqrt((a(1,1)-b(1,1))^2 + (a(1,2)-b(1,2))^2 + (a(1,3)-b(1,3))^2);

d1 = sqrt((b(1,1)-c(1,1))^2 + (b(1,2)-c(1,2))^2 + (b(1,3)-c(1,3))^2);

d2 = sqrt((c(1,1)-a(1,1))^2 + (c(1,2)-a(1,2))^2 + (c(1,3)-a(1,3))^2);

cos_C = (d1^2 + d2^2 - d3^2)/(2*d1*d2);

cos_B = (d3^2 + d1^2 - d2^2)/(2*d3*d1);

cos_A = (d2^2 + d3^2 - d1^2)/(2*d2*d3);

x0 = optical_center;

%calculate the distance between the optical center and the three

%control points

da = sqrt((a(1,1)-x0(1,1))^2 + (a(1,2)-x0(1,2))^2 + (a(1,3)-x0(1,3))^2);

db = sqrt((b(1,1)-x0(1,1))^2 + (b(1,2)-x0(1,2))^2 + (b(1,3)-x0(1,3))^2);

dc = sqrt((c(1,1)-x0(1,1))^2 + (c(1,2)-x0(1,2))^2 + (c(1,3)-x0(1,3))^2);

%calculate the tree angles between the optical center and the the three

%control points: alpha, beta and gamma

c1 = (db^2+dc^2-d1^2)/(2*db*dc);

c2 = (da^2+dc^2-d2^2)/(2*da*dc);

c3 = (db^2+da^2-d3^2)/(2*db*da);

%sign of the delta angels

sign_cos = zeros(3,1);

sign_cos(1) = sign(c1 - cos_A);

sign_cos(2) = sign(c2 - cos_B);

sign_cos(3) = sign(c3 - cos_C);

%the two curves

syms U V

f1 = (U^2 + (d2^2-d1^2)/(d2^2)*(V^2) - 2*U*V*c1 + 2*(d1^2)/(d2^2)*V*c2 - (d1^2)/(d2^2))*(1);

f2 = (U^2 - (d3^2)/(d2^2)*(V^2) + 2*V*(d3^2)/(d2^2)*c2 - 2*U*c3 + (d2^2 - d3^2)/(d2^2))*(1);

[Us, Vs] = solve(f1,f2);

matlab 2014的答案是:

s_u =

0.0179459498256680 + 0.00000000000000i

0.236878368248324 + 0.00000000000000i

1.04400374689170 - 2.36218161398276i

1.04400374689170 + 2.36218161398276i

s_v =

0.566024623784037 + 0.00000000000000i

-0.207364159971325 + 0.00000000000000i

1.28263695385604 - 2.65197121306296i

1.28263695385604 + 2.65197121306296i

但是matlab 2011的答案是:

s_u =

1.33807934021580 + 0.00000000000000i

0.0406664782040968 + 0.00000000000000i

0.549618993663444 + 1.11520983744082i

0.549618993663444 - 1.11520983744082i

s_v =

1.72081216830722 + 0.00000000000000i

-0.313433844873907 + 0.00000000000000i

0.758278024045738 + 1.14608234099226i

0.758278024045738 - 1.14608234099226i

他们是完全不同的。 在类似的情况下,Matlab 2011永远是对的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值