25 views (last 30 days)

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 3x3 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?

Steven Lord
on 24 Sep 2020 at 15:59

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?

Steven Lord
on 24 Sep 2020 at 19:21

You're welcome! And your English was good, I could understand what you said without a problem.

Opportunities for recent engineering grads.

Apply TodayFind the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 0 Comments

Sign in to comment.