# Inverting large matrices

Hi All - any hints on inverting large I'll conditioned matrices? Doing an LM test and it goes crazy every now and then because of his...

0

You could try using olsqr or the slash operator '/', with an identity matrix as the response variable. The LU and QR algorithms are more numerically stable and may work.

``````inverse = olsqr(eye(rows(A)), A);
inverse = eye(rows(A))/A;``````

If that does not work, you could add a small coefficient to the diagonal of the matrix and try the inversion. The definition of small, of course, will depend on the scale of your matrix. Ideally, you want to add the smallest constant such that the inversion appears sane.

``````lambda = 1e-7 .* eye(rows(A));
inverse = invpd(A + lambda);``````

aptech

1,773

0

You could try using olsqr or the slash operator '/', with an identity matrix as the response variable. The LU and QR algorithms are more numerically stable and may work.

``````inverse = olsqr(eye(rows(A)), A);
inverse = eye(rows(A))/A;``````

If that does not work, you could add a small coefficient to the diagonal of the matrix and try the inversion. The definition of small, of course, will depend on the scale of your matrix. Ideally, you want to add the smallest constant such that the inversion appears sane.

``````lambda = 1e-7 .* eye(rows(A));
inverse = invpd(A + lambda);``````