Asked by Ross
on 28 Apr 2013

Hi

I have a GA running a stiffness matrix. This involves inverting a large matrix. Using the function inv() in some cases the warning message is returned from inv()

"Matrix is close to singular or badly scaled"

I understand the error and i know the why this error occurs. (The GA choses a extreme solution) is there a way of testing for this.

essentially

if Matrix is close to singular or badly scaled == true %throw out solution end

As sometime a badly scaled solution becomes the optimum i would simply like to remove all badly scaled solutions but i need a way of testing for the condition.

Ross

*No products are associated with this question.*

Answer by the cyclist
on 28 Apr 2013

The cond() function returns the condition number.

>> doc cond

for details.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 1 Comment

## Matt J (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/73870#comment_145949

I don't have the specifics of what you're doing, but using inv() is often unnecessary and performs poorly, esepcially with large matrices. You should be using A\B instead of inv(A)*B.