System of linear equations
조회 수: 1 (최근 30일)
이전 댓글 표시
u1, u2, v1, v2, w1, w2 are each 5 by 5 matrix. Following pair of linear equations hold at each grid, for example
At (1,1 ): c1*u1(1,1) + c2*v1(1,1) = w1(1,1)
and c1*u2(1,1) + c2*v2(1,1) = w2(1,1)
At (1,2 ): c1*u1(1,2) + c2*v1(1,2) = w1(1,2)
and c1*u2(1,2) + c2*v2(1,2) = w2(1,2)
...
At (5,5): c1*u1(5,5) + c2*v1(5,5) = w1(5,5)
and c1*u2(5,5) + c2*v2(5,5) = w2(5,5).
How can I solve for c1 and c2 (each in 5 by 5 matrix form)?
댓글 수: 2
Walter Roberson
2021년 5월 9일
Could you confirm that you need this solved in Simulink? If so then would using a MATLAB Function Block be acceptable, or do you need to make it out of more basic blocks ?
답변 (1개)
Walter Roberson
2021년 5월 9일
c1*u1(1,1) + c2*v1(1,1) = w1(1,1)
How can I solve for c1 and c2 (each in 5 by 5 matrix form)?
If c1 and c2 are 5 x 5, then the implication is that at each location (J,K) in the grid, c1*u1(J,K) + c2*v1(J,K) = w1(J,K) but c1 and c2 are 5 x 5, so the left side would be 5 x 5 and the right side would be a consistent scalar. That would imply that
c1 = (w1(J,K) - c2*v1(J,K))./u1(J,K)
c1 = w1(J,K)./u1(J,K) - c2*(v1(J,K)./u1(J,K))
and that has to hold for all J,K, with c1 and c2 being the same 5 x 5 matrices for each J,K location.
And at the same time,
c1 = w2(J,K)./u2(J,K) - c2*(v2(J,K)./u2(J,K))
This leads to
c1 = (v2.*w1 - v1.*w2) ./ (u1.*v2 - u2.*v1)
c2 = (u1.*w2 - u2.*w1) ./ (u1.*v2 - u2.*v1)
But are you sure that is the equation system you want??
댓글 수: 2
Walter Roberson
2021년 5월 9일
c12 = [u1(:), v1(:); u2(:), v2(:)] \ [w1(:); w2(:)];
c1 = reshape(c12(1:25), 5, 5);
c2 = reshape(c12(26:end), 5, 5);
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!