solve a linear system of equations with several unknown parameters
8 次查看(过去 30 天)
显示 更早的评论
hello ,
I have a system V*F=u with
V= [2 1 1; 4 1 1; 4 2 1; 2 2 1]
F=[f11, f21;f12, f22;g1, g2]
and u= [10,10;10,5 ;10,4; 40 ,40]
and i want to sove it in order to find f11,f12,f21,f22,g1 ang g2. I tried with this code but i get warning msg :Solution does not exist because the system is inconsistent.
I am not sure this is the right way to solve such a system
syms f11 f12 f21 f22 g1 g2
V=[2 1 1; 4 1 1; 4 2 1; 2 2 1] ;
F=[f11 f21;f12 f22;g1 g2];
U=[10,10;10,5 ;10,4; 40 ,40] ;
L=V*F;
eqn1 = L(1,1) == U(1,1);
eqn2 = L(1,2) == U(1,2);
eqn3 =L(2,1) == U(2,1);
eqn4 =L(2,2) == U(2,2);
eqn5 =L(3,1) == U(3,1);
eqn6 =L(3,2) == U(3,2);
eqn7 =L(4,1) == U(4,1);
eqn8 =L(4,2) == U(4,2);
[D,E] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4, eqn5,eqn6,eqn7,eqn8], [f11, f12,f21,f22 g1,g2]);
Ug = linsolve(D,E);
thank you in advance.
0 个评论
采纳的回答
Steven Lord
2022-11-8
syms f11 f12 f21 f22 g1 g2
V=[2 1 1; 4 1 1; 4 2 1; 2 2 1] ;
F=[f11 f21;f12 f22;g1 g2];
U=[10,10;10,5 ;10,4; 40 ,40] ;
L=V*F == U
Subtract the second equation in the first column from the third.
L(3, 1)-L(2, 1)
This tells us that f12 must be 0. Now subtract the fourth equation in the first column from the first.
L(4, 1)-L(1, 1)
This tells us that f12 must be 30. Is there a number that is simultaneously equal to 0 and equal to 30?
FM = V\U
check = V*FM-U
3 个评论
Torsten
2022-11-9
编辑:Torsten
2022-11-9
This is what Steven Lord tried to explain: your equations are contradictory and thus do not have a "solution" in the usual sense.
But as always, you can find FM that "best" solves your equations in the sense that norm(V*FM-U) is minimized. For a "solution" in the usual sense, norm(V*FM-U) would be 0.
更多回答(1 个)
Torsten
2022-11-8
编辑:Torsten
2022-11-8
You have 8 equations for 6 unknowns. The consequence in general is that there is no solution that satisfies the 8 equations exactly, but only in the least-squares sense. This is also the case here:
syms f11 f12 f21 f22 g1 g2
V=[2 1 1; 4 1 1; 4 2 1; 2 2 1] ;
F=[f11 f21;f12 f22;g1 g2];
U=[10,10;10,5 ;10,4; 40 ,40] ;
L=V*F;
eqn1 = L(1,1) == U(1,1);
eqn2 = L(1,2) == U(1,2);
eqn3 =L(2,1) == U(2,1);
eqn4 =L(2,2) == U(2,2);
eqn5 =L(3,1) == U(3,1);
eqn6 =L(3,2) == U(3,2);
eqn7 =L(4,1) == U(4,1);
eqn8 =L(4,2) == U(4,2);
[D,E] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4, eqn5,eqn6,eqn7,eqn8], [f11, f12,f21,f22 g1,g2])
%Ug = linsolve(D,E);
Ug = double(D)\double(E)
double(D)*Ug-double(E)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!