How to generate a badly conditioned matrix?

14 visualizaciones (últimos 30 días)
Beaya
Beaya el 9 de Nov. de 2013
Editada: Matt J el 9 de Nov. de 2013
I want to test how, badly conditioning of a matrix A, will affect calculation of A*x = b where A is my increasingly badly conditioned matrix and x is a vector of ones, so we know the exact solution. This is my code, however it gives me correct results no matter how badly conditioned my matrix is. Do you have any suggestions on what am I doing wrong?
n = 31;
for a = 1:n-1;
A = gallery('randsvd',a,a,4);
%disp(A)
x = ones(a,1);
b = A*x;
xGauss=A\b
xInv=inv(A)*b
end

Respuestas (1)

Matt J
Matt J el 9 de Nov. de 2013
Editada: Matt J el 9 de Nov. de 2013
I don't think you've actually checked cond(A). Your matrices aren't all that ill-conditioned, for any a=1...30. Here's an example where you can see the effects of ill-conditioning
for a = 1:n-1;
A=vander(1:a);
x = ones(a,1);
b = A*x;
errorSlash=norm(A\b-1)
errorInv=norm(inv(A)*b-1)
end

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by