solve a linear system of equations with several unknown parameters

8 views (last 30 days)
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.

Accepted Answer

Steven Lord
Steven Lord on 8 Nov 2022
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
L = 
Subtract the second equation in the first column from the third.
L(3, 1)-L(2, 1)
ans = 
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)
ans = 
This tells us that f12 must be 30. Is there a number that is simultaneously equal to 0 and equal to 30?
Now if you wanted a least-squares solution use the mldivide function or the \ operator:
FM = V\U
FM = 3×2
-7.5000 -10.2500 15.0000 14.5000 17.5000 23.7500
check = V*FM-U
check = 4×2
7.5000 7.7500 -7.5000 -7.7500 7.5000 7.7500 -7.5000 -7.7500
  3 Comments
Torsten
Torsten on 9 Nov 2022
Edited: Torsten on 9 Nov 2022
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.

Sign in to comment.

More Answers (1)

Torsten
Torsten on 8 Nov 2022
Edited: Torsten on 8 Nov 2022
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])
D = 
E = 
%Ug = linsolve(D,E);
Ug = double(D)\double(E)
Ug = 6×1
-7.5000 15.0000 -10.2500 14.5000 17.5000 23.7500
double(D)*Ug-double(E)
ans = 8×1
7.5000 7.7500 -7.5000 -7.7500 7.5000 7.7500 -7.5000 -7.7500

Community Treasure Hunt

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

Start Hunting!