Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Systems of equations in matlab

  1. Aug 20, 2011 #1
    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
  2. jcsd
  3. Aug 21, 2011 #2


    User Avatar
    Science Advisor

    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 [itex][T1,T2,T3]^T[/itex] and c is a vector of your constants.

    Hint. From the above, the first row of M would be [1, -B, 0].
    Last edited: Aug 21, 2011
  4. Aug 21, 2011 #3
    "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 )
  5. Aug 21, 2011 #4
    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
    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
  6. Aug 21, 2011 #5


    User Avatar
    Science Advisor

    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
  7. Aug 21, 2011 #6


    User Avatar
    Science Advisor

    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: Aug 21, 2011
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook