MATLAB 3 equations and 3 unknowns

  • Context: MATLAB 
  • Thread starter Thread starter Elecomputer
  • Start date Start date
  • Tags Tags
    Matlab Unknowns
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 5K views
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.