MATLAB MATLAB 3 equations and 3 unknowns

  • Thread starter Thread starter Elecomputer
  • Start date Start date
  • Tags Tags
    Matlab Unknowns
AI Thread Summary
The discussion revolves around solving a system of linear equations in MATLAB, specifically the equations ax + by + cz = d, ex + fy + gz = h, and ix + jy + kz = l. The user initially attempts to solve the equations using matrix division with the syntax A/b, where A is the coefficient matrix and b is the constant matrix. However, they receive clarification that using A\b is indeed the correct method, as it is equivalent to multiplying the inverse of A by b. Additionally, another user suggests using the reduced row echelon form (rref) function, which can help identify unique solutions by transforming the augmented matrix [A b]. If a unique solution exists, the output should show the identity matrix alongside the solution values for x, y, and z.
Elecomputer
Messages
8
Reaction score
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
Hello,

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

Have a good day,
J.
 
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.
 

Similar threads

Replies
4
Views
1K
Replies
6
Views
2K
Replies
1
Views
3K
Replies
9
Views
2K
Back
Top