필터 지우기
필터 지우기

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

조회 수: 2 (최근 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.
Abb
Abb 2023년 5월 17일
@Torsten I just updated the question with known values to help to repreduce the issue.

댓글을 달려면 로그인하십시오.

채택된 답변

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
Abb
Abb 2023년 5월 17일
@Torsten Thanks alot, could you please write down the equation behind this code?
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에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by