eqn1 = 
how to solve simultaneous equations?
Afficher commentaires plus anciens
Dear sir/madam,
I need to solve two simultaneous linear equations. How could I do this in matlab? Looking forward to hearing from you soon.
Thanking you, BSD
1 commentaire
MUYIDEEN MOMOH
le 24 Mar 2019
Question
3x+2y=12
4x+6y=18
Matlab code
A=[3, 2 ; 4, 6];
B=[12; 18];
sol=linsolve(A,B)
Réponse acceptée
Plus de réponses (4)
Ishika Shivahre
le 10 Mar 2021
0 votes
x1+x2=1
0.718+y2 = 1
x1*P"= 0.718*86.8
x2*P2" = y2* 86.8
1 commentaire
syms x1 x2 y2 P_dprime P2_dprime
eqn1 = x1 + x2 == 1
eqn2 = 0.718 + y2 == 1
eqn3 = x1 * P_dprime == 0.718*86.8
eqn4 = x2 * P2_dprime == y2 * 86.8
sol = solve([eqn1, eqn2, eqn3, eqn4], [x1, x2, y2, P_dprime])
That is as far as you can get. You have 4 equations in 5 variables, so you cannot solve for all of them simultaneously.
Yaavendra Ramsaroop
le 4 Mai 2021
0 votes
A=[3, 2 ; 4, 6];
B=[12; 18];
sol=linsolve(A,B)
Step 1: Express your equations into an Augmented Matrix where each equation represents a row of that matrix (excluding the answers/ the value beyond "=" sign.), assign the matrix to a variable. Let say A.
Step 2: Form a column matrix of the answers/ values beyond the "=" sign. Assign the column matrix to another variable B.
Step 3: Compute the solution by 'linsolve()' function OR sipmly A\B=inverse(A)*B
Solution=linsolve(A,B)
SHRDRACK
le 30 Avr 2024
Modifié(e) : Walter Roberson
le 30 Avr 2024
A=[3, 2 ; 4, 6];
B=[12; 18];
sol=inv(A)*B
enter in comand window
2 commentaires
It is not recommended that you use inv() for this purpose; it is less precise then some of the alternatives.
A=[3, 2 ; 4, 6];
B=[12; 18];
sol=A\B
Hi @SHRDRACK, In my Grade 10 Math class, my teacher taught me this method of solving a system of linear equations. It's natural to use the inv() command when searching online for how to compute the inverse of a square matrix. Interestingly, even the professor who taught my Numerical Methods course never showed me the trick of Left Matrix Division using "A\b" like @Walter Roberson did.





A = [3, 2; 4, 6];
b = [12; 18];
% step 1
detA = det(A)
% step 2
adjA = adjoint(A)
% step 3
invA = (1/detA)*adjA
% step 4
x = invA*b
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!