Here is a possible implementation of function myinvk(k)
in MATLAB, which computes the inverse of a 3x3 calibration matrix k
without using the built-in function inv()
:
main.m717 chars18 lines
This function implements the formula for the inverse of a 3x3 matrix using the adjugate matrix, which is the transpose of the matrix of cofactors. The determinant of the matrix is computed with the Laplace expansion along the first row. The result is stored in a new matrix ki
of the same size as k
. Note that this function assumes that the input matrix k
is invertible.
To test this function, you can create a 3x3 matrix k
and compare the result of myinvk(k)
with the built-in function inv(k)
:
main.m178 chars10 lines
This should output:
main.m246 chars13 lines
As you can see, the results of myinvk(k)
and inv(k)
are identical up to machine precision.
gistlibby LogSnag