Warning: Matrix is close to singular or badly scaled.
Show older comments
Hello I am playing around with a code for that has been uploaded by Biswa Datta https://uk.mathworks.com/matlabcentral/fileexchange/2155-numerical-linear-algebra-and-applications/content/datta/CHAP8/rayqot.m. If I use
B=[16 2 3 13;5 11 10 8;9 7 6 12;4 14 15 1];
ep=0.0000005;
nmax=1000;
x0=ones(n,1);
I get this message: Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.691450e-17.
How would one go about this problem?
5 Comments
John BG
on 16 Mar 2017
JR
the link you have supplied in your question returns

would it be possible for you to supply code instead?
regards
@John BG: I've removed the parenthesis from the link and in is working now.
@JR: What is n? Do you call the function like this:
[sigma,x,iter] = rayqot(B, x0, ep, nmax)
John D'Errico
on 16 Mar 2017
Edited: John D'Errico
on 16 Mar 2017
But the link you show and the small amount of code you supply does not include how you are trying to call the function. Yes, I think I know how you are calling it. But be helpful to others, making it easy for them to help you.
JR
on 17 Mar 2017
Jan
on 19 Mar 2017
@JR: You are welcome. Questions for clarifications belong to the standard process of solving problems.
Accepted Answer
More Answers (1)
ones(n,1) is a "bad" initial approximation to the eigen vector, because it is the result also. In the first iteration
sigma = (x'*A*x)/(x'*x);
xhat = (A-sigma * eye(n,n))\x;
solves a system, which is close to singular. When the initial guess is too good, the algorithm shows the warning, but still calculated the correct result.
Either choose a different initial guess or take into account that the first step has an inaccurate result.
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!