How Do I Solve Systems of Equations in MATLAB?

Click For Summary

Discussion Overview

The discussion revolves around solving a system of equations in MATLAB, specifically a set of equations involving variables T1, T2, and T3, with known constants A, B, T0, and T4. Participants explore methods for rearranging the equations into a suitable form for matrix representation and discuss MATLAB functionalities for solving such systems.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant presents a system of equations involving T1, T2, and T3 and seeks guidance on solving it using MATLAB.
  • Another participant suggests rewriting the equations to isolate the unknowns on the left-hand side (LHS) and constants on the right-hand side (RHS), proposing a matrix form Mt = c.
  • A subsequent reply questions the accuracy of the RHS representation of the equations, indicating potential discrepancies in the formulation.
  • Further contributions reiterate the need to keep the unknowns on the LHS and provide a method for constructing the matrix M and vector c with numerical values.
  • One participant advises against using the matrix inverse for solving unless a unique solution is guaranteed, recommending row reduction as a more efficient method.
  • Another participant explains the use of the rref() function in MATLAB for row reducing the augmented matrix.

Areas of Agreement / Disagreement

Participants express differing views on the correct formulation of the RHS of the equations, indicating a lack of consensus. There are also varying opinions on the best approach to solve the system in MATLAB, with some favoring matrix inversion and others advocating for row reduction.

Contextual Notes

Participants mention the need for numerical values for the known constants to construct the matrix and vector properly. There are unresolved aspects regarding the exact formulation of the equations and the implications of using different solving methods.

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:

Similar threads

  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
Replies
18
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 34 ·
2
Replies
34
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
11
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K