Problem with solve() and "Empty sym: 0-by-1".

42 vues (au cours des 30 derniers jours)
Kacper Hankus
Kacper Hankus le 16 Avr 2024 à 16:08
Commenté : Steven Lord le 16 Avr 2024 à 21:21
I am trying to run the program listed below, however the only result I am geting is every "alfa" variable being "Empty sym: 0-by-1". I think that the problem comes from matrix A's dimensions (4x4) because this problem does not occur when it is smaller. How can I solve this problem?
Ax = [0 1 0 0; 0 -0.1 0 0.8; 0 0 -4 9; -1 -9 2 -8]
Ax = 4x4
0 1.0000 0 0 0 -0.1000 0 0.8000 0 0 -4.0000 9.0000 -1.0000 -9.0000 2.0000 -8.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Bx = [0 0 0 0; 0 0 -0.5 0; -2 -2 0 2; 4 0 0 0]
Bx = 4x4
0 0 0 0 0 0 -0.5000 0 -2.0000 -2.0000 0 2.0000 4.0000 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
syms a01 a02 a03 a04 a11 a12 a13 a23 a14
[alfa01, alfa11] = solve(Ax*Ax*Bx(:,1) == a01*Bx(:,1) + a11*Ax*Bx(:,1), a01, a11)
alfa01 = Empty sym: 0-by-1 alfa11 = Empty sym: 0-by-1
[alfa02, alfa12] = solve(Ax*Ax*Bx(:,2) == a02*Bx(:,2)+a12*Ax*Bx(:,2), a02, a12)
alfa02 = Empty sym: 0-by-1 alfa12 = Empty sym: 0-by-1
[alfa03, alfa13, alfa23] = solve(Ax*Ax*Ax*Bx(:,3) == a03*Bx(:,3)+a13*Ax*Bx(:,3)+a23*Ax*Ax*Bx(:,3),a03, a13, a23)
alfa03 = Empty sym: 0-by-1 alfa13 = Empty sym: 0-by-1 alfa23 = Empty sym: 0-by-1
[alfa04, alfa14] = solve(Ax*Ax*Bx(:,2) == a04*Bx(:,4)+a14*Ax*Bx(:,4), a04, a14)
alfa04 = Empty sym: 0-by-1 alfa14 = Empty sym: 0-by-1

Réponses (2)

Steven Lord
Steven Lord le 16 Avr 2024 à 16:18
Let's look at the systems of equations you're trying to solve.
Ax = [0 1 0 0; 0 -0.1 0 0.8; 0 0 -4 9; -1 -9 2 -8];
Bx = [0 0 0 0; 0 0 -0.5 0; -2 -2 0 2; 4 0 0 0];
syms a01 a02 a03 a04 a11 a12 a13 a23 a14
expr1 = Ax*Ax*Bx(:,1) == a01*Bx(:,1) + a11*Ax*Bx(:,1)
expr1 = 
This one clearly has no solution, since 16/5 is not equal to 0.
expr2 = Ax*Ax*Bx(:,2) == a02*Bx(:,2)+a12*Ax*Bx(:,2)
expr2 = 
Again, no solution since -16/5 is not equal to 0.
expr3 = Ax*Ax*Ax*Bx(:,3) == a03*Bx(:,3)+a13*Ax*Bx(:,3)+a23*Ax*Ax*Bx(:,3)
expr3 = 
This one might have a solution. We can use the third equation to get the value of a_23 and then use either the first or fourth equation to get the value of a_13. We can then use the other of the fourth or first equation to check if those values of a_23 and a_13 are consistent.
a_23 = solve(expr3(3))
a_23 = 
a_13 = solve(subs(expr3(1), a23, a_23))
a_13 = 
check = subs(expr3(4), [a23 a13], [a_23, a_13])
check = 
simplify(check)
ans = 
symfalse
So no, the equations are not consistent.
expr4 = Ax*Ax*Bx(:,2) == a04*Bx(:,4)+a14*Ax*Bx(:,4)
expr4 = 
And again, no solution because of the second equation.
So MATLAB returning the empty 0-by-1 sym for each of those systems is correct.
  2 commentaires
Kacper Hankus
Kacper Hankus le 16 Avr 2024 à 16:32
Values that I have provided were simplified (I was testing something), real values are:
Ax = [0 1 0 0;
0 -0.114285714285714 0 0.000857142857142857;
0 0 -40431.7380106209 9692.83899105876;
-124860009.337019 -9424083769.63351 212.464324132108 -840.736575441009]
Bx = [0 0 0 0;
0 0 -0.571428571428571 0;
-21324245780.3293 -26896536642.1169 0 286624203821656;
467421513.090638 0 0 0]
Is MATLAB correct on this one as well?
Steven Lord
Steven Lord le 16 Avr 2024 à 21:21
There are no Bug Reports for Symbolic Math Toolbox in release R2023b, so I assume the toolbox is operating correctly. But you don't have to take my word for it. You can look at the expressions you're trying to solve and do the same type of analysis I did for your third set of equations to see if the equations are consistent.

Connectez-vous pour commenter.


Bruno Luong
Bruno Luong le 16 Avr 2024 à 17:03
Modifié(e) : Bruno Luong le 16 Avr 2024 à 17:16
Your equations look illposed to me for three reasons*
For a given j, LHS are known (4 x 1) vector
Ax*Ax*B(:,j),
let's call it
C(:,j) := Ax*Ax*B(:,j).
RHS is
(alpha0 + alpja1)*Bx(:;,j)
So any alpha0, alpja1 that sum to the same value s = (alpha0 + alpja1) give the same RHS vector. This is the first reason why the eqt is illèposed. The solution s for each component i #i is
s = B(i,j)/Cii,j) for i=1, ..., 4.
You can check it, these ratios are not the same for i = 1,... 4. Second reason of illposedness
And you work obviously with numerical data, you should not use symbolic that assumes the data are exact.ly entered. Third reason of illposedness.

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by