Search code examples
matlabmatrixlinear-algebramatrix-inverse

inverse of a matrix


in matlab inverse of matlab can be written:

For least squares ( more efficient)

x = A\b.--------------------------------1

But for covariance matrix (Qxx) of unknown paramters(x), I usually do,

Qxx==inv(A) --------------------------2

How I can write it in efficient way like (1)?


Solution

  • You mean something like:

    Qxx = A \ eye(size(A));
    

    ?

    Real question is, what are you doing with the inverse? If you're just remultiplying it by some other vector c then you can just do...

    A \ c
    

    instead of Qxx * c