Why I'm getting empty values for the unknowns [a0, a1, a2, b0, b1, b2] using solve function?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Torsten
am 17 Mai 2023
Bearbeitet: Torsten
am 17 Mai 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)
a1 = sol(2)
a2 = sol(3)
b0 = sol(4)
b1 = sol(5)
b2 = sol(6)
2 Kommentare
Torsten
am 17 Mai 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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!