# How to write cramer's rule 3x3 by matlab ?

402 Ansichten (letzte 30 Tage)
ENG. Mohamed Ibrahim am 10 Mär. 2016
Beantwortet: Asif Iqbal am 28 Jan. 2022
How to write cramer's rule 3x3 by matlab ?
##### 1 KommentarKeine anzeigenKeine ausblenden
James Tursa am 10 Mär. 2016
What have you done so far? Do you know how to replace elements in a matrix with other elements? Do you know how to use a for loop? Do you know how to calculate the determinant of a matrix?

Melden Sie sich an, um zu kommentieren.

### Antworten (3)

Explorer am 10 Mär. 2016
Bearbeitet: Explorer am 10 Mär. 2016
Question: Find the system of Linear Equations using Cramers Rule:
2x + y + z = 3
x – y – z = 0
x + 2y + z = 0
The above example is taken from http://www.purplemath.com/modules/cramers.htm
% Demo Code:
A = [2 1 1; 1 -1 -1; 1 2 1] % Coefficient Matrix
X = [3; 0; 0]
Ax = [3 1 1 ; 0 -1 -1;0 2 1 ]
Ay = [2 3 1; 1 0 -1; 1 0 1]
Az = [2 1 3; 1 -1 0; 1 2 0]
detA=det(A)
x = det(Ax)/detA
y = det(Ay)/detA
z = det(Az)/detA
##### 5 Kommentare4 ältere Kommentare anzeigen4 ältere Kommentare ausblenden
James Tursa am 15 Jan. 2021
Rather than creating the modified matrix with concatenation, a direct assignment of the column:
k = the column number to replace
mNAM = NAM;
mNAM(:,k) = I;
This could easily be put into a loop.

Melden Sie sich an, um zu kommentieren.

Faith Ira Daro am 24 Nov. 2021
given the linear equations:
3x+2y = -5
-5x+7y=1
solve for the values of x and y using cramers rule
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Asif Iqbal am 28 Jan. 2022
% Demo Code:
A = [2 1 1; 1 -1 -1; 1 2 1] % Coefficient Matrix
X = [3; 0; 0]
Ax = [3 1 1 ; 0 -1 -1;0 2 1 ]
Ay = [2 3 1; 1 0 -1; 1 0 1]
Az = [2 1 3; 1 -1 0; 1 2 0]
detA=det(A)
x = det(Ax)/detA
y = det(Ay)/detA
z = det(Az)/detA
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Linear Algebra in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!