MATLAB: Fix inv warning in matlab fix inv warning in matlab I use this code: b=inv(A'*A)*A'*y; Matlab gives warning. never use inv to solve linear system How can I fix it? Best Answer b=inv(A'*A)*A'*y; Multiply both sides on the left by A'*A :(A'*A) * b = (A'*A) * inv(A'*A) * A' * yand for any invertable matrix, X * inv(X) is the identity matrix so (A'*A) * inv(A'*A) cancels out to identity, so(A'*A) * b = A' * yMultiply both sides on the left by inv(A'):inv(A') * A' * A * b = inv(A') * A' * yand inv(A') * A' cancels to the identity on both sides, soA * b = yMultiply by inv(A) on the left on both sides:inv(A) * A * b = inv(A) * yinverse cancels to identity, sob = inv(A) * yNow use the \ operator:b = A \ y;The above mathematics might not strictly apply if A is not a square matrix. Related SolutionsMATLAB: Eigenvalues and orthonormal eigenvectors Yes there is. Look at the eig function. MATLAB: Subscript indices must either be real positive integers or logicals There is a more fundamental issue here:inv(A + u*u')=invA - 1/Z * invA * u*u' * invAThe above line indicates that you need to go over some basic MATLAB tutorials. You can't just type and equation with variables on both sides and solve it like you would in Maple or Mathematica. While:New = inv(A + u*u')is a perfectly valid line:inv(A + u*u') = Newis not. Related QuestionInvers from covariance of a matrix*matrix’Need to obtain two unknown coefficients
Best Answer