How to use one code to solve different system of equations?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm new to matlab and I'm absolutely lost of how to work this program. I'm trying to solve three different system of equations with only one code, that computes a row echelon form of any 3x4 matrix and a reduce row echelon form of any 3x4 matrix without using the rref() command. Thank you so much in advance.
The system of equations:
1. 2x1 − 3x2 + x3 = 2
−x1 − x2 + 5x3 = −2
3x1 − 2x2 − x3 = 5
2. −4x2 + 2x3 = 5
−x1 + 3x3 = 2
3x1 − 2x2 = 1
3. −4x2 + x3 = −2
−x1 − x2 + 5x3 = −3
7x1 − 2x2 = −1
3 commentaires
Stephen23
le 22 Avr 2020
Original question by Rachel trent, recovered from Google Cache:
"How to use one code to solve different system of equations?"
I'm new to matlab and I'm absolutely lost of how to work this program. I'm trying to solve three different system of equations with only one code, that computes a row echelon form of any 3x4 matrix and a reduce row echelon form of any 3x4 matrix without using the rref() command. Thank you so much in advance.
The system of equations:
1. 2x1 − 3x2 + x3 = 2
−x1 − x2 + 5x3 = −2
3x1 − 2x2 − x3 = 5
2. −4x2 + 2x3 = 5
−x1 + 3x3 = 2
3x1 − 2x2 = 1
3. −4x2 + x3 = −2
−x1 − x2 + 5x3 = −3
7x1 − 2x2 = −1
Réponses (1)
Anirudh Singh
le 17 Avr 2020
Create augumanted matrix (A) form the euqation , then use following code :
function A = row_echelon(A)
[m,n]=size(A);
for j=1:min(m,n)
A(j,:) = A(j,:)/A(j,j);
for i = j+1:m
A(i,:)= A(i,:)- A(j,:)*A(i,j);
end
end
end
Note : This code does not work when A(j,j)=0, So try to madify logic in this code according to your requirements.
0 commentaires
Voir également
Catégories
En savoir plus sur Linear Algebra 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!