I would like to get an invertible matrix in Octave but as integers matrix, so:
x = [9,15;19,2];
inv(x)
Here I get:
[-0.0074906, 0.0561798; 0.0711610, -0.0337079]
but I would like to get [22,17;25,21]
anyone knows how to invert a matrix?
To flip a matrix about the horizontal axis (up to down), call the flipud function. To flip a matrix about the vertical axis (left to right), call the fliplr function. These functions are from Matlab and so work in it too.
Y = inv( X ) computes the inverse of square matrix X . X^(-1) is equivalent to inv(X) .
FAQs on Inverse of Identity Matrix Since the product of the identity matrix with itself is equal to the identity matrix, therefore the inverse of identity matrix is the identity matrix itself.
To find the inverse of a 2x2 matrix: swap the positions of a and d, put negatives in front of b and c, and divide everything by the determinant (ad-bc).
The inverse of each element is:
x .^ -1
Which results
0.1111 0.0667
0.0526 0.5000
Why you want to get [22,17;25,21]
? What mathematical operation would yield such result?
You are confused about what an inverse of a matrix is, don't nobody here knows what you want with your output, so here are some clues.
If you Invert an identity matrix, you get the identity matrix:
octave:3> a = [1,0;0,1]
a =
1 0
0 1
octave:4> inv(a)
ans =
1 0
0 1
Non-square matrices (m-by-n matrices for which m != n) do not have an inverse
x = [9,15;19,2;5,5];
inv(x)
%error: inverse: argument must be a square matrix
Inverting a matrix with a zero on the diagonal causes an infinity:
octave:5> a = [1,0;0,0]
a =
1 0
0 0
octave:6> inv(a)
warning: inverse: matrix singular to machine precision, rcond = 0
ans =
Inf Inf
Inf Inf
Inverting a matrix with full values like this:
octave:1> a = [1,2;3,4]
a =
1 2
3 4
octave:2> inv(a)
ans =
-2.00000 1.00000
1.50000 -0.50000
For a description of what is happening under the hood of the inverse function:
https://www.khanacademy.org/math/precalculus/precalc-matrices/inverting_matrices/v/inverse-of-a-2x2-matrix
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With