For loop for system of equations

조회 수: 2 (최근 30일)
Vincent Gambuzza
Vincent Gambuzza 2020년 2월 10일
답변: Jyothis Gireesh 2020년 2월 13일
I need to solve this system of equations with a for loop so that the dimensions match. I would like to loop through the “b” matrix
  댓글 수: 1
darova
darova 2020년 2월 10일
Can you please show your attempts? What have you tried?

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

답변 (1개)

Jyothis Gireesh
Jyothis Gireesh 2020년 2월 13일
The methodology outlined in the image attached may not be the most suitable one for this case. The recommended way to solve the system of equations given above may be to use the “mldivide” operator in MATLAB. So, the matrix may be calculated as
x = A\b;
But using the above methods yields the following warning message
‘Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.202823e-18’.
One possible work-around in this case is to use the pseudo-inverse of A. The following code may be used to compute “x”
x = pinv(A)*b;
which gives
x = -1.0556 -2.5556 -4.0556
0.1111 0.1111 0.1111
1.2778 2.7778 4.2778
Please refer to the following documentation link on “pinv” to get further clarification on calculating pseudo-inverse.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by