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 CenterFile Exchange에서 State-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