Number of solutions of a system of linear equations
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gunther Schaaf
le 28 Juil 2018
Réponse apportée : Dimitris Kalogiros
le 28 Juil 2018
I am looking for MATLAB code to determine the number of solutions (0, 1, Inf) of a system of linear equations (m equations for n variables, e. g.
A=[2,1,3;0, -1,5];
b=[-3;1]
x=A\b
which has infinitely many solutions.
While the answer for the m=n case is given in this excellent post making use of the rank() function I wonder how it can be solved in the general case (m=n, m>n, m<n).
0 commentaires
Réponse acceptée
Dimitris Kalogiros
le 28 Juil 2018
Hi Gunther.
You can use solve() within symbolic toolbox.
I'm giving you an example:
syms x y z
eqn1= 2*x + y + 3*z==-3
eqn2= -y + 5*z==1
sol = solve([eqn1, eqn2], [x, y, z], 'ReturnConditions',true);
disp('Solution is :')
[sol.x; sol.y; sol.z]
disp('With parameters : ')
sol.parameters
disp('Under the conditions :')
sol.conditions
Function solve() returns the one solution of the system , or entirely set of solutions if the system has infinite solutions. In case the system has no solutions, sol.x , sol.y , and sol.z are empty.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Equation Solving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!