You can use the inv
function to find the inverse of a matrix in MATLAB. Given a matrix A
, the syntax is:
main.m15 chars2 lines
Here's an example:
main.m32 chars3 lines
The output would be:
main.m50 chars4 lines
Note that not all matrices have an inverse, and in general it's best to avoid using inv
when possible, as it can be numerically unstable. Instead, you can use \
to solve linear equations, like so:
main.m10 chars2 lines
where b
is a column vector representing the right-hand side of the equation Ax = b
.
gistlibby LogSnag