Systems of equations in matlab

In summary, the conversation discusses how to use MATLAB to solve a system of equations and suggests using matrix form and row reduction to find the solution. The conversation also mentions a typo in the original equations and provides tips for using the rref function in MATLAB.
  • #1
loukoumas
15
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
  • #2
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:
  • #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 )
 
  • #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
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
 
  • #5
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
 
  • #6
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:

Related to Systems of equations in matlab

1. How do I solve a system of equations in MATLAB?

To solve a system of equations in MATLAB, you can use the "solve" function. This function takes in two arguments, the equations and the variables, and returns the values of the variables that satisfy the equations. For example, if your equations are x + y = 5 and x - y = 1, you can use the command "solve([x+y=5, x-y=1], [x,y])" to solve for the values of x and y.

2. Can I solve a system of equations with more than two variables in MATLAB?

Yes, MATLAB can solve systems of equations with any number of variables. You just need to make sure that you have the same number of equations as variables. If you have more equations than variables, you can use the "solve" function with the additional argument "ReturnConditions" set to true. This will return the solutions as well as any additional conditions that need to be satisfied.

3. How do I plot the solutions of a system of equations in MATLAB?

To plot the solutions of a system of equations in MATLAB, you can use the "ezplot" function. This function takes in the equations and the variables and plots the solutions on a graph. For example, if your equations are x + y = 5 and x - y = 1, you can use the command "ezplot([x+y=5, x-y=1], [x,y])" to plot the solutions on a graph.

4. Can I use matrices to solve a system of equations in MATLAB?

Yes, you can use matrices to solve a system of equations in MATLAB. You can use the "linsolve" function, which takes in the coefficient matrix and the constant vector as arguments, to solve the system. This is useful when you have a large number of equations and variables.

5. How do I check if a system of equations has a unique solution in MATLAB?

To check if a system of equations has a unique solution in MATLAB, you can use the "rank" function. This function takes in the coefficient matrix and returns the number of linearly independent rows or columns. If the rank of the coefficient matrix is equal to the number of variables, then the system has a unique solution. Otherwise, it has either no solution or infinite solutions.

Similar threads

  • Special and General Relativity
Replies
9
Views
302
  • Engineering and Comp Sci Homework Help
Replies
16
Views
3K
  • Introductory Physics Homework Help
Replies
13
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
2K
  • Introductory Physics Homework Help
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
11
Views
1K
  • Introductory Physics Homework Help
Replies
18
Views
2K
  • Introductory Physics Homework Help
Replies
34
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
Back
Top