Extract values from one matrix and with iteration solve the system of linear equations
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone!
Please, help me write a code for solving the system of linear equations in Matlab
If I have a column of coefficients A [A1;A2;A3] and the inverse matrix 3x3 B^(-1) and unknown column C [C1, C1, C1] (here all values are equal)
I have to find C1 value and plot the graph. Also A1 values can be extraacted from another matrix, so unknowns are A2, A3 and C1
A.'*B^(-1) = C
2 commentaires
Torsten
le 3 Oct 2022
A is 3x1, B^(-1) is 3x3, thus A*B^(-1) is not defined. Maybe you mean
A.'*B^(-1) = C
instead of
A*B^(-1)=C1
?
Réponses (2)
Torsten
le 4 Oct 2022
Modifié(e) : Torsten
le 4 Oct 2022
B = rand(3,3);
A1 = 4;
rhs = -A1*B(1,:).';
Mat = [-ones(3,1),B(2:3,:).'];
sol = Mat\rhs;
C1 = sol(1)
A2 = sol(2)
A3 = sol(3)
[A1 A2 A3]*B-[C1 C1 C1]
3 commentaires
Torsten
le 4 Oct 2022
Use a loop:
B = rand(3,3);
A1 = [4,pi,-80,329];
C1 = zeros(size(A1));
A2 = zeros(size(A1));
A3 = zeros(size(A1));
for i=1:numel(A1)
rhs = -A1(i)*B(1,:).';
Mat = [-ones(3,1),B(2:3,:).'];
sol = Mat\rhs;
C1(i) = sol(1);
A2(i) = sol(2);
A3(i) = sol(3);
[A1(i) A2(i) A3(i)]*B-[C1(i) C1(i) C1(i)];
end
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!