Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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 comentarios
Abb
Abb el 17 de Mayo de 2023
Editada: Abb el 17 de Mayo de 2023
@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 el 17 de Mayo de 2023
@Torsten I just updated the question with known values to help to repreduce the issue.

Iniciar sesión para comentar.

Respuesta aceptada

Torsten
Torsten el 17 de Mayo de 2023
Editada: Torsten el 17 de Mayo de 2023
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 comentarios
Abb
Abb el 17 de Mayo de 2023
@Torsten Thanks alot, could you please write down the equation behind this code?
Torsten
Torsten el 17 de Mayo de 2023
- 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)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by