MATLAB: Something is wrong with the Matlab

3x3helpmathMATLABsystem of equation

Hi, today I saw a challenge on internet, so I decided to solve it using math and Matlab to check if I was right.
It was about a 3×3 system of equations.
The equation was:
A = [x x x; x y y; y -2z]
b = [60 30 3]'
And this is what I used.
A = [1 1 1; 1 1 1; 0 1 -2]
b = [60 30 3]'
When I found out the values of x, y and z, the values were: x = 20, y = 5 and z = 1.
But, on Matlab, they showed me the values for x = 16.28, y = 20 and z = 8.5.
I used the "A\b" command and after I used the "pinv(A)*b" command.
What I did wrong? Can you help me with that?

Best Answer

A = [x x x; x y y; y -2z]
b = [60 30 3]'
I suspect this is supposed to represent the equations 3*x = 60, x+2*y = 30, y-2*z = 3. That's not how I would have written them, but the question you're asking is about how to write them.
A = [1 1 1; 1 1 1; 0 1 -2]
b = [60 30 3]'
Those two matrices represent the equations x+y+z = 60, x+y+z = 30, y-2*z = 3. Those don't match the equations from the original problem, and the first two equations aren't consistent. How can the sum of x, y, and z simultaneously be equal to 60 and equal to 30?
The first element of the first row of your A should be the coefficient of the first variable in the first equation.
The second element of the first row of your A should be the coefficient of the second variable in the first equation.
The first element of the third row of your A should be the coefficient of the first variable in the third equation.
Can you translate the original equations into A using this pattern?