How to use one code to solve different system of equations?

3 ビュー (過去 30 日間)
Rachel Trent
Rachel Trent 2020 年 4 月 13 日
コメント済み: Rena Berman 2020 年 5 月 14 日
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 件のコメント
Stephen23
Stephen23 2020 年 4 月 22 日
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
Rena Berman
Rena Berman 2020 年 5 月 14 日
(Answers Dev) Restored edit

サインインしてコメントする。

回答 (1 件)

Anirudh Singh
Anirudh Singh 2020 年 4 月 17 日
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.

カテゴリ

Help Center および File ExchangeState-Space Control Design and Estimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by