MATLAB How Do I Solve Systems of Equations in MATLAB?

AI Thread Summary
To solve the system of equations in MATLAB, first rewrite the equations to isolate the unknowns on the left-hand side and constants on the right-hand side, forming a matrix equation of the form Mt = c. Once the matrix M and vector c are established with known numerical values, you can solve for the unknowns using the equation t = inv(M) * c. However, it is often more efficient to use row reduction for solving systems, which can handle cases with no unique solution; this can be done by augmenting the matrix with the vector c and applying the rref() function. Additionally, there was a mention of an issue saving notebooks in Mathematica due to a wrong path error. Understanding these methods will facilitate solving the equations effectively in MATLAB.
loukoumas
Messages
14
Reaction score
0
hello everybody!

T1=A T1'+B(T0'+T2'+T0+T2)
T2=A T2'+B(T1'+T3'+T1+T3)
T3=A T3'+B(T2'+T4'+T2+T4)
if A,B,T0,T4 and everything in (') character is known, i have T1,T2,T3 to find and 3 equations. how do i use MATLAB to solve this?(i have a 9X9 system to solve but i guess it's the same)

Also,good someone know why i can't save my notebooks in mathematica?
It gives me a message about wrong path!

thank you very much
 
Physics news on Phys.org
Rewrite your equations so that you have linear combinations of the unknowns on the LHS and fold all the constants together on the RHS. For example with the first of your equations,

1 T1 - B T2 + 0 T3 = (A T' + B T0' + B T2' + B T0)

When you've finished you'll be able to write your set of equations in matrix form Mt = c, where M is a matrix, t the vector [T1,T2,T3]^T and c is a vector of your constants.

Hint. From the above, the first row of M would be [1, -B, 0].
 
Last edited:
"For example with the first of your equations,

1 T1 - B T2 + 0 T3 = (-A T' + B T0' + T0)" wouldn't be the RHS a little different??
1 T1 - B T2 + 0 T3 = A T1' + B ( T0' + T2' + T0 )
 
if i am right about the RHS, my system will get at the form:
[M]t=A t' + [N] t' + B c where c is [T'0+TO
0
T'4+T4]
How MATLAB can now help me? i guess i need to leave t alone on the LHS!
i haven't worked in MATLAB before, so i know so little about it
thank you for your time and of course for your help
 
loukoumas said:
if i am right about the RHS, my system will get at the form:
[M]t=A t' + [N] t' + B c where c is [T'0+TO
0
T'4+T4]
How MATLAB can now help me? i guess i need to leave t alone on the LHS!
i haven't worked in MATLAB before, so i know so little about it
thank you for your time and of course for your help

Yeah I fixed the typo's on the RHS. I was trying to type that while cooking dinner. :redface:

If you have numerical values for everything that you said is "known", then you can construct matrix M and vector c (with actual numbers right).

In MATLAB you can solve the equation M t = c by just pre-multiplying both sides by the inverse of M

t = inv(M) * c
 
Just to add one thing. While using the matrix inverse is a good way to solve a set of equations if you know that they have a unique solution, in general it is often better to use "row reduce" which is both efficient and can handle the case where there is not a single solution.

To use row reduction you should augment the vector c to the matrix, as in X = [M , c], and then just type rref(X) to row reduce it.

BTW. The rather cryptically named rref() function stands for "Row Reduced Echelon Form".
 
Last edited:
Back
Top