The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Tweaking Singular Matrices
Replies: 12   Last Post: Mar 22, 2012 3:37 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bjorn Gustavsson

Posts: 430
Registered: 12/7/04
Re: Tweaking Singular Matrices
Posted: Mar 21, 2012 7:20 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Cory" wrote in message <jkde2j$dmh$>...
> Hi all,
> In some code I am writing, there will occasionally be some regularities in the problem that yield (essentially) singular matrices which I am supposed to use to solve a system of linear equations. As an illustrative example, I might have:
> A = [1 2 3 0 0; 4 5 6 0 0; 7 8 9 0 0; 0 0 0 1 -1; 0 0 0 -1 1]
> b = [1; 2; 3; 0; 0]
> and I want to solve Ax = b. Of course there are multiple solutions.
> What is the easiest way for MATLAB to detect which rows are part of a non-singular portion so I can substitute an arbitrary value in for those equations. e.g. in the figure above, I would want to substitute an arbitrary equation for the 4th or 5th one.
> I can think of some awkward ways to do this, but would appreciate any advice on the most elegant way.

Shouldn't this be what singular value decomposition is for?
[U,S,V] = svd(A);
indx_true_null = find(diag(S)==0);
indx_num_null = find(diag(S)<eps); % perhaps diag(S)/max(diag(S))<eps
% In null:
% In numerical null:

I guess you could use matlab's null function as well.

My 5 p.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.