필터 지우기
필터 지우기

Solve matrix equations using loop

조회 수: 2 (최근 30일)
Alina Abdikadyr
Alina Abdikadyr 2022년 10월 8일
댓글: Torsten 2022년 10월 8일
Hello everyone!
I have a matrix A(3x3)
A= (2 10 15
3 5 -7
3 -2 -2 )
And Matrx B (3x1)
B = (B1
B2
B3)
Matrix C (3x1), where all values are equal to each other
C= (C1
C1
C1)
So, I need using loop, solve the equations and find the values of C1, B2 and B3. B1 is known for me, and has 125 elements. For each B1, I have to find C1, B2 and B3 respectively
Solve the equation A*B=C
Thank you in advance!
  댓글 수: 3
Alina Abdikadyr
Alina Abdikadyr 2022년 10월 8일
A*B=C

댓글을 달려면 로그인하십시오.

답변 (1개)

Chunru
Chunru 2022년 10월 8일
The equations you have:
You want to solve it for , and . You need to rearrage the equations:
Now you solve this new system of equations with unknowns as :
A = [ 2 10 15
3 5 -7
3 -2 -2 ];
Anew = [-ones(3, 1) A(:, 2:3)];
AnewInv = inv(Anew);
b1 = rand(5,1); % rand(125,1) or your data
for i=1:length(b1)
bnew = -b1(i)*A(:, 1);
res = AnewInv*bnew %[c1; n2; b3]
end
res = 3×1
0.9814 0.0096 0.0134
res = 3×1
1.8311 0.0178 0.0250
res = 3×1
0.9554 0.0093 0.0130
res = 3×1
1.8897 0.0184 0.0258
res = 3×1
0.4087 0.0040 0.0056

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by