Hi,
For a school exercise I need to use Cramer's rule to determine Ax=b.
I need to execute this using a for loop. Currently I'm facing an issue where if I replace the column's off A by, they will remain b so that my next determinant (x2) is not correct. How do I get the original (a1) column back in the second loop, (and again for the third en fourth)?
my current code:
A = [1,1,-3,2;0,-1,4,0;-3,1,2,2;1,2,3,6]
b = [1;2;3;4]
detA = det(A)
[z,z] = size(A);
for g = 1:z;
A(:,g) = b
x = det(A)
end
Cheers,
Matthias

4 comentarios

Jan
Jan el 2 de Oct. de 2018
Editada: Jan el 22 de Dic. de 2018
The current code has not relation to the Cramer's rule. Overwriting all values of A by b is not useful. Please check the definition of the Cramer's rule again and restart from scratch.
Matthias Bossenbroek
Matthias Bossenbroek el 2 de Oct. de 2018
Dear Jan,
Thank you for your feedback. I am trying to applying the method used in the picture. Calculating all the determinants will be done after i fixed my current issue.
Kind regards, Matthias
Anusha Sridharan
Anusha Sridharan el 9 de En. de 2019
[Answers Dev] Restored Edits
Rakib Seemanto
Rakib Seemanto el 1 de Nov. de 2020
how to find the value of x and y by using Cramer’s rule from these equations:
𝑎𝑥+𝑏𝑦=𝑐 and 𝑑𝑥+𝑒𝑦=𝑓 ???

Iniciar sesión para comentar.

 Respuesta aceptada

KSSV
KSSV el 3 de Oct. de 2018
Editada: KSSV el 3 de Oct. de 2018

0 votos

A = rand(3) ;
b = rand(3,1) ;
[m,n] = size(A) ;
x = zeros(m,1) ;
for i = 1:m
T = A ;
T(:,i) = b ;
x(i) = det(T)/det(A) ;
end
% Simply use \
sol = A\b ;
[x sol]

1 comentario

Rakib Seemanto
Rakib Seemanto el 1 de Nov. de 2020
how to find the value of x and y by using Cramer’s rule from these equations:
𝑎𝑥+𝑏𝑦=𝑐 and 𝑑𝑥+𝑒𝑦=𝑓 ???

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear Algebra en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 1 de Oct. de 2018

Comentada:

el 1 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by