Sysem
Sysem

Reputation: 1

MATLAB Matrix Problem

I have a system of equations (5 in total) with 5 unknowns. I've set these out into matrices to try solve, but I'm not sure if this comes out right. Basically the setup is AX = B, where A,X, and B are matrices. A is a 5x5, X is a 1x5 and B is a 5x1.

When I use MATLAB to solve for X using the formula X = A\B, it gives me a warning:

Matrix is singular to working precision.

and gives me 0 for all 5 X unknowns, but if I say X = B\A it doesnt, and gives me values for the 5 X unknowns.

Anyone know what I'm doing wrong? In case this is important, this is what my X matrix looks like:

X= [1/C3; 1/P1; 1/P2; 1/P3; 1/P4]

Where C3, P1, P2, P3, P4 are my unknowns.

Upvotes: 0

Views: 1347

Answers (2)

Chris A.
Chris A.

Reputation: 6887

So, the next thing is to figure out why A is singular. (Note that it's possible that you'd want to solve

A x = b

in cases with square and singular A, but they'd only be in cases where b is in the range space of A.)

Maybe you can write your matrix A and vector b out (since it's only 5x5)? Or explain how you create it. That might give a clue as to why A isn't full rank or as to why b isn't in the range space of A.

Upvotes: 0

Phonon
Phonon

Reputation: 12727

Your matrix is singular, which means its determinant is 0. Such system of equations does not give you enough information to find a unique solution. One odd thing I see in your question is that X is 1x5 while B is 5x1. This is not a correct way of posing the problem. Both X and B must be 5x1. In case you're wondering, this is not a Matlab thing - this is a linear algebra thing. This [5x5]*[1x5] is illegal. This [5x5]*[5x1] produces a [5x1] result. This [1x5]*[5x5] produces a [1x5] result. Check you algebra first, and then check whether the determinant (det function in Matlab) is 0.

Upvotes: 3

Related Questions