Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Matrix is singular

Subject: Matrix is singular

From: MAY

Date: 20 Apr, 2011 16:32:18

Message: 1 of 8

Hi All,

I am having trouble running my code - basically I keep getting this warning message

" Matrix is close to singular or badly scaled.
         Results may be inaccurate. RCOND = 2.652873e-20. "

The matrix A is an nxn and I am doing something like this

(A+...)\(....)

A is not symmetric and det(A)=0.

I looked everywhere on how to make a sigular matrix non-singular so that the above operation is made possible but couldn't find a solution.

Any help is much appreciated.

Thanks!

PS: I looked at the NAG Toolbox but I couldn't reproduce the example they provided.

Subject: Matrix is singular

From: Roger Stafford

Date: 20 Apr, 2011 17:23:05

Message: 2 of 8

"MAY " <ma87@hotmail.co.uk> wrote in message <ion1qi$kqs$1@fred.mathworks.com>...
> Hi All,
>
> I am having trouble running my code - basically I keep getting this warning message
>
> " Matrix is close to singular or badly scaled.
> Results may be inaccurate. RCOND = 2.652873e-20. "
>
> The matrix A is an nxn and I am doing something like this
>
> (A+...)\(....)
>
> A is not symmetric and det(A)=0.
>
> I looked everywhere on how to make a sigular matrix non-singular so that the above operation is made possible but couldn't find a solution.
>
> Any help is much appreciated.
>
> Thanks!
>
> PS: I looked at the NAG Toolbox but I couldn't reproduce the example they provided.
- - - - - - - - -
  You can't just "make a singular matrix non-singular" without changing the nature of the problem you are working on. The fact that you are getting such warnings undoubtedly indicates either that 1) where you hoped there would be a unique solution to the posed problem, there are actually infinitely many solutions or perhaps none, or 2) the solution you obtain is very sensitive to small errors in prior calculations and is therefore likely to be excessively inaccurate. You have to work your way out of such a difficulty by revising the statement of your problem or the approach you are taking to it in some way or to honestly acknowledge that the problem could not be solved as stated.

Roger Stafford

Subject: Matrix is singular

From: Emma Robertson

Date: 20 Apr, 2011 18:06:05

Message: 3 of 8


> 1) where you hoped there would be a unique solution to the posed problem, there are > actually infinitely many solutions or perhaps none.

yes you're right, there are more than one solution... but how does that help in finding the inverse?

The one-dimensional problem can be solved easily as I don't need to divide by a matrix (or rather find the inverse), but in the 2-D problem it becomes necessary to invert the matrix.

Many thanks

Subject: Matrix is singular

From: dpb

Date: 20 Apr, 2011 18:11:05

Message: 4 of 8

On 4/20/2011 1:06 PM, Emma Robertson wrote:
>
>> 1) where you hoped there would be a unique solution to the posed
>> problem, there are > actually infinitely many solutions or perhaps none.
>
> yes you're right, there are more than one solution... but how does that
> help in finding the inverse?
>
> The one-dimensional problem can be solved easily as I don't need to
> divide by a matrix (or rather find the inverse), but in the 2-D problem
> it becomes necessary to invert the matrix.

A) Doesn't

B) Insufficient data altho in general it's rare that one actual has to
perform the physical inversion; most often there are alternate solution
techniques than the brute force.

What, specifically, depends on the actual problem for which you've given
no useful clues (other than it's very ill-conditioned).

--

Subject: Matrix is singular

From: Emma Robertson

Date: 20 Apr, 2011 18:36:04

Message: 5 of 8


> A) Doesn't

what doesn't?

> B) Insufficient data altho in general it's rare that one actual has to
> perform the physical inversion; most often there are alternate solution
> techniques than the brute force.
>
> What, specifically, depends on the actual problem for which you've given
> no useful clues (other than it's very ill-conditioned).

okay here is an example of a 10x10 matrix A that I am trying to find
(A+constants)\(constants +another matrix) for.

A=
    2.7773 2.7769 2.7767 2.7766 2.7766 2.7766 2.7766 2.7767 2.7769 2.7773
    2.7769 2.7764 2.7760 2.7758 2.7757 2.7757 2.7758 2.7760 2.7764 2.7769
    2.7767 2.7760 2.7755 2.7752 2.7750 2.7750 2.7752 2.7755 2.7760 2.7767
    2.7766 2.7758 2.7752 2.7748 2.7746 2.7746 2.7748 2.7752 2.7758 2.7766
    2.7766 2.7757 2.7750 2.7746 2.7745 2.7745 2.7746 2.7750 2.7757 2.7766
    2.7766 2.7757 2.7750 2.7746 2.7745 2.7745 2.7746 2.7750 2.7757 2.7766
    2.7766 2.7758 2.7752 2.7748 2.7746 2.7746 2.7748 2.7752 2.7758 2.7766
    2.7767 2.7760 2.7755 2.7752 2.7750 2.7750 2.7752 2.7755 2.7760 2.7767
    2.7769 2.7764 2.7760 2.7758 2.7757 2.7757 2.7758 2.7760 2.7764 2.7769
    2.7773 2.7769 2.7767 2.7766 2.7766 2.7766 2.7766 2.7767 2.7769 2.7773

Subject: Matrix is singular

From: Roger Stafford

Date: 20 Apr, 2011 19:10:21

Message: 6 of 8

"Emma Robertson" wrote in message <ion92k$rtj$1@fred.mathworks.com>...
> ......
> okay here is an example of a 10x10 matrix A that I am trying to find
> (A+constants)\(constants +another matrix) for.
>
> A=
> 2.7773 2.7769 2.7767 2.7766 2.7766 2.7766 2.7766 2.7767 2.7769 2.7773
> 2.7769 2.7764 2.7760 2.7758 2.7757 2.7757 2.7758 2.7760 2.7764 2.7769
> ........
- - - - - - - -
  Unless those added constants in "A+constants" are just right (and apparently they aren't,) this is the situation I mentioned - your results are subject to massive errors because of the near singularity of A+constants. That is what matlab is attempting to warn you about. Being annoyed with the warning is a little like punishing the messenger who brings you unhappy news. Would you rather not know about such problems?

Roger Stafford

Subject: Matrix is singular

From: dpb

Date: 20 Apr, 2011 21:18:42

Message: 7 of 8

On 4/20/2011 1:36 PM, Emma Robertson wrote:
>
>> A) Doesn't
>
> what doesn't?

> yes you're right, there are more than one solution... but how
> does that help in finding the inverse?

The answer was that it doesn't (help in finding the inverse, that is)...

>> B) Insufficient data altho in general it's rare that one actual has to
>> perform the physical inversion; most often there are alternate
>> solution techniques than the brute force.
>>
>> What, specifically, depends on the actual problem for which you've
>> given no useful clues (other than it's very ill-conditioned).
>
> okay here is an example of a 10x10 matrix A that I am trying to find
> (A+constants)\(constants +another matrix) for.
>
> A=
> 2.7773 2.7769 2.7767 2.7766 2.7766 2.7766 2.7766 2.7767 2.7769 2.7773
> 2.7769 2.7764 2.7760 2.7758 2.7757 2.7757 2.7758 2.7760 2.7764 2.7769
...

Bleeech!!! As Roger says, you're shooting the messenger here, it seems.

What are the constraints on "constants" and how are you trying to
compute them?

What's the actual problem/context? That might provide other clues as to
alternate approaches.

--

Subject: Matrix is singular

From: dpb

Date: 21 Apr, 2011 00:18:37

Message: 8 of 8

On 4/20/2011 1:36 PM, Emma Robertson wrote:
...
> okay here is an example of a 10x10 matrix A ...
> A=
> 2.7773 2.7769 2.7767 2.7766 2.7766 2.7766 2.7766 2.7767 2.7769 2.7773
> 2.7769 2.7764 2.7760 2.7758 2.7757 2.7757 2.7758 2.7760 2.7764 2.7769
> 2.7767 2.7760 2.7755 2.7752 2.7750 2.7750 2.7752 2.7755 2.7760 2.7767
> 2.7766 2.7758 2.7752 2.7748 2.7746 2.7746 2.7748 2.7752 2.7758 2.7766
> 2.7766 2.7757 2.7750 2.7746 2.7745 2.7745 2.7746 2.7750 2.7757 2.7766
> 2.7766 2.7757 2.7750 2.7746 2.7745 2.7745 2.7746 2.7750 2.7757 2.7766
> 2.7766 2.7758 2.7752 2.7748 2.7746 2.7746 2.7748 2.7752 2.7758 2.7766
> 2.7767 2.7760 2.7755 2.7752 2.7750 2.7750 2.7752 2.7755 2.7760 2.7767
> 2.7769 2.7764 2.7760 2.7758 2.7757 2.7757 2.7758 2.7760 2.7764 2.7769
> 2.7773 2.7769 2.7767 2.7766 2.7766 2.7766 2.7766 2.7767 2.7769 2.7773

01 2.7773 2.7769 2.7767 2.7766 2.7766 2.7766 2.7766 2.7767 2.7769 2.7773
10 2.7773 2.7769 2.7767 2.7766 2.7766 2.7766 2.7766 2.7767 2.7769 2.7773

02 2.7769 2.7764 2.7760 2.7758 2.7757 2.7757 2.7758 2.7760 2.7764 2.7769
09 2.7769 2.7764 2.7760 2.7758 2.7757 2.7757 2.7758 2.7760 2.7764 2.7769

03 2.7767 2.7760 2.7755 2.7752 2.7750 2.7750 2.7752 2.7755 2.7760 2.7767
08 2.7767 2.7760 2.7755 2.7752 2.7750 2.7750 2.7752 2.7755 2.7760 2.7767

04 2.7766 2.7758 2.7752 2.7748 2.7746 2.7746 2.7748 2.7752 2.7758 2.7766
07 2.7766 2.7758 2.7752 2.7748 2.7746 2.7746 2.7748 2.7752 2.7758 2.7766

05 2.7766 2.7757 2.7750 2.7746 2.7745 2.7745 2.7746 2.7750 2.7757 2.7766
06 2.7766 2.7757 2.7750 2.7746 2.7745 2.7745 2.7746 2.7750 2.7757 2.7766

I didn't initially recognize just _how_ degenerate your case is;
sometimes one can standardize a set of coefficients and work around an
ill-conditioned design matrix in that fashion. So, I did and it was
still singular to machine precision.

However in standardized form, the similarity of the values was more
obvious visually so it popped off the screen.

Only half of the rows are unique; the other half are identical to their
mate. Clearly there's no way you're going to make this system
non-degenerate w/o some major perturbation.

One possible set of constants to allow you to invert the resultant
matrix would be eye(10) :)

--

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us