Why I'm getting empty values for the unknowns [a0, a1, a2, b0, b1, b2] using solve function?

1 次查看(过去 30 天)
I'm going to find the values for [a0, a1, a2, b0, b1, b2] by having 5 of knowns coordinates (u,v), (x_n,y_n)? why I'm getting empty values?
u = [73.430, 9.522, 491.183, 569.351, 577.275];
v = [730.723, 1311.200, 1286.046, 676.560, 1868.456];
x_n = [88, 26, 503, 577, 594];
y_n = [740, 1326, 1296, 688, 1872];
syms a0 a1 a2 b0 b1 b2
eqn1 = x_n - a0 + a1*u + a2*v==0;
eqn2 = y_n - b0 + b1*u + b2*v==0;
sol = solve([eqn1, eqn2], [a0, a1, a2, b0, b1, b2]);
  3 个评论
Abb
Abb 2023-5-17
编辑:Abb 2023-5-17
@Torsten I have no idea about regression, but my goal is finding the unknown values. Just that. I have the values for u,v and x_n, y_n, and looking for other values.

请先登录,再进行评论。

采纳的回答

Torsten
Torsten 2023-5-17
编辑:Torsten 2023-5-17
u = [73.430, 9.522, 491.183, 569.351, 577.275].';
v = [730.723, 1311.200, 1286.046, 676.560, 1868.456].';
x_n = [88, 26, 503, 577, 594].';
y_n = [740, 1326, 1296, 688, 1872].';
A = [-ones(5,1), u, v, zeros(5,1), zeros(5,1), zeros(5,1);zeros(5,1), zeros(5,1), zeros(5,1), -ones(5,1),u,v];
b = [-x_n;-y_n];
sol = A\b;
a0 = sol(1)
a0 = 9.1045
a1 = sol(2)
a1 = -0.9903
a2 = sol(3)
a2 = -0.0065
b0 = sol(4)
b0 = 16.1529
b1 = sol(5)
b1 = 0.0068
b2 = sol(6)
b2 = -0.9966
  2 个评论
Torsten
Torsten 2023-5-17
- a0 + a1*u(i) + a2*v(i)=-x_n(i) (i=1,...,5)
- b0 + b1*u(i) + b2*v(i)=-y_n(i) (i=1,...,5)
Thus 10 equations in 6 unknowns. You cannot expect that all equations are satisfied with equality. The code above solves for the unknowns by minimizing
sum_{i=1}^{i=10} error(i)^2
with
error(i) = x_n(i) - a0 + a1*u(i) + a2*v(i) (i=1,...,5)
error(5+i) = y_n(i) - b0 + b1*u(i) + b2*v(i) (i=1,...,5)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by