MATLAB 3 equations and 3 unknowns

In summary, the conversation discusses using MATLAB to solve a problem involving a system of equations. The main question is about the syntax for solving a general case, and there are various suggestions and approaches given by the participants. Some suggest using A\b, while others suggest using rref() to find the solution. Ultimately, the conversation ends with the advice to use A\b to solve for x, y, and z.
  • #1
Elecomputer
8
0
Hello,

I have never really used MATLAB before, and I was assigned some homework on it. While I was able to solve most of them, I was unable to solve this one in particular, even after searching the internet and documentation, there was many kinds that I was left confused.

Does anyone know the syntax for this general case:

ax+by+cz=d
ex+fy+gz=h
ix+jy+kz=l (<- awesome I got vector components to match with x,y,z)

And I'd like to solve for x, y, z.

This is what I tried:

A = [a,b,c;e,f,g;i,j,k]
b = [d;h;l]

and then A/b.

This gives me three numbers (in my case, I'm not using letters)

Is this the correct approach?

All help is appreciated.
 
Physics news on Phys.org
  • #2
Hello,

I think the correct way is A\b , which is equivalent to inv(A)*b.

Have a good day,
J.
 
  • #3
You could use
Code:
rref([A b])

If there is a unique solution, the answer should be the identity matrix with an extra column on the right, which contains the solutions for x, y, and z.
 

1. What is MATLAB and how does it solve equations?

MATLAB is a high-level programming language used for mathematical computations, data analysis, and visualization. It has built-in functions and tools that allow users to easily solve equations by simply inputting the equations and unknown variables. MATLAB uses numerical methods to solve equations, making it a powerful tool for solving complex systems of equations.

2. How can I input 3 equations and 3 unknowns in MATLAB?

To input 3 equations and 3 unknowns in MATLAB, you can use the symbolic variables function. This allows you to create symbolic variables for each unknown and then write the equations using those variables. For example, if your unknown variables are x, y, and z, you can create them using the command 'syms x y z' and then write your equations using these variables.

3. Can I solve systems of equations with more than 3 unknowns in MATLAB?

Yes, MATLAB can solve systems of equations with any number of unknowns. However, the number of equations must be equal to the number of unknowns in order to get a unique solution. If there are more equations than unknowns, MATLAB will use its built-in algorithms to find the best approximation for the solution.

4. How accurate are the solutions obtained from solving 3 equations and 3 unknowns in MATLAB?

The accuracy of the solutions obtained from solving 3 equations and 3 unknowns in MATLAB depends on the complexity of the equations and the numerical methods used. In general, MATLAB provides accurate solutions up to a certain number of decimal places. However, for highly complex or ill-conditioned systems of equations, the solutions may have a higher margin of error.

5. Can I plot the solutions obtained from solving 3 equations and 3 unknowns in MATLAB?

Yes, you can plot the solutions obtained from solving 3 equations and 3 unknowns in MATLAB. After solving the system of equations, you can use the 'plot' function to create a visual representation of the solutions. This is particularly useful for systems of equations with two unknowns, as the solutions can be plotted on a 2D graph.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • Introductory Physics Homework Help
Replies
1
Views
993
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
547
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
937
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
Back
Top