Solve 100 equations, each with a different amount of unknowns in matlab
7 次查看(过去 30 天)
显示 更早的评论
Hi folks,
I have 100 equations which I want to solve simultaneously. There are 9 unknowns (A, B, C, D, E, F, G, H, J). Not each equation has 9 unknowns.
Below are a couple of the equations which I am trying to solve simultaneously (I'm aware there may be limitations considering not each equation has the same unknowns, but considering there is so many equations I'm hoping the computational capabilities of matlab could bypass this issue?).
PGASiteCorrectedIntraResidual(21)= 0.8965*B
PGASiteCorrectedIntraResidual(22)= 1.4350*F + 0.2272*B
PGASiteCorrectedIntraResidual(23)= 0.1902*K + 1.5069*L
PGASiteCorrectedIntraResidual(24)= 1.3683*F
PGASiteCorrectedIntraResidual(25)= 1.3260*L
PGASiteCorrectedIntraResidual(26)= 1.4388*L
PGASiteCorrectedIntraResidual(27)= 0.1428*A + 1.3456*E + 0.1208*F
PGASiteCorrectedIntraResidual(28)= 1.7080*F
PGASiteCorrectedIntraResidual(29)= 0.9675*B + 0.4395*F
PGASiteCorrectedIntraResidual(30)= 1.1125*F
PGASiteCorrectedIntraResidual(31)= 0.3608*A + 1.1628*E + 0.2967*F
PGASiteCorrectedIntraResidual(32)= 1.1762*C
PGASiteCorrectedIntraResidual(33)= 1.2025*F + 0.0642*B
PGASiteCorrectedIntraResidual(34)= 1.2082*F + 0.0638*B
PGASiteCorrectedIntraResidual(35)= 1.5749*F
PGASiteCorrectedIntraResidual(36)= 0.2690*A + 0.8727*B + 0.7128*F
PGASiteCorrectedIntraResidual(37)= 1.3713*L
PGASiteCorrectedIntraResidual(38)= 0.7236*B + 0.7163*F
PGASiteCorrectedIntraResidual(39)= 0.7961*B + 0.7752*F
PGASiteCorrectedIntraResidual(40)= 1.8229*E + 0.2857*F + 0.4807*B
PGASiteCorrectedIntraResidual(41)= 1.9081*A + 0.7745*B
PGASiteCorrectedIntraResidual(42)= 0.3616*K + 1.7008*L
PGASiteCorrectedIntraResidual(43)= 0.7649*B + 0.8394*F
PGASiteCorrectedIntraResidual(44)= 1.8750*A + 1.0423*B
PGASiteCorrectedIntraResidual(45)= 2.2159*B + 0.5612*C
PGASiteCorrectedIntraResidual(46)= 2.2250*E + 0.4393*D
Is there a function in matlab which could solve for these unknowns easily?
Thanks for any help
0 个评论
采纳的回答
Bjorn Gustavsson
2019-6-13
What you have (shown) is a linear system of equations, with 100 equations and only 9 unknowns. This is exactly what matlab is designed to solve. Since the system is rather overdetermined, 91 more equations than unknowns, it is likely that all equations cannot be solved exactly at the same time, but you should be able to get a least-square solution without problems. What you should do is to create a matrix, M, with the coefficients for each equation row-by-row. After you've done that you have a simple matrix equation:
PGAS_vector = M*ABCDEFGHI;
Where the ABCDEFGHI array is an array with your 9 unknowns, and the PGAS_vector is the column-vector with all your PGASiteCorrectedIntraResidual components. Matlab is expertly designed to solve this type of overdetermined equations:
ABCDEFGHI = M\PGAS_vector;
That way you get a least-square solution for all your 9 unknowns.
Now, if the equations you've not shown contains non-linear terms in the unknowns this is not a solution.
HTH
4 个评论
Bjorn Gustavsson
2019-6-13
Yes, it should have as many rows as you have in M - the number of equations. You should get somewtinh like this from whos:
>> whos
Name Size Bytes Class Attributes
M 100x9 168 double
PGAS_vector 100x1 56 double
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!