필터 지우기
필터 지우기

solve a linear system of equations with several unknown parameters

조회 수: 1 (최근 30일)
tty
tty 2022년 11월 8일
댓글: tty 2022년 11월 9일
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.

채택된 답변

Steven Lord
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
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
Torsten
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.
tty
tty 2022년 11월 9일
ah ok. Thank you both for the replies.

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

추가 답변 (1개)

Torsten
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])
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

카테고리

Help CenterFile Exchange에서 Stability Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by