how do i use the in-built inv function to calculate a matrix inverse and then calculate A-1A and AA-1.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
David Craven
el 6 de Sept. de 2017
Respondida: James Tursa
el 6 de Sept. de 2017
how do i use the in-built inv function to calculate a matrix inverse and then calculate A-1A and AA-1.
1 comentario
Respuesta aceptada
Cam Salzberger
el 6 de Sept. de 2017
Hello David,
Strictly speaking, you would do it like this:
Ainv = inv(A);
Ainv*A
A*Ainv
However, as Stephen pointed out, there are faster and more accurate methods for calculating the inverse when you plan to solve linear equations or include it in some matrix algebra. These two commands are mathematically equivalent, but will be faster and more precise:
A\A % equivalent to Ainv*A
A/A % equivalent to A*Ainv
-Cam
2 comentarios
David Craven
el 6 de Sept. de 2017
Editada: James Tursa
el 6 de Sept. de 2017
Cam Salzberger
el 6 de Sept. de 2017
Editada: Cam Salzberger
el 6 de Sept. de 2017
Well, if line 2 of that file is:
Inverse = %calculate the inverse of a matrix with the inv function
then that looks incomplete to me. Maybe you should just remove those lines, and keep it to the other lines only.
-Cam
Más respuestas (1)
James Tursa
el 6 de Sept. de 2017
The comment character % needs to be at the beginning of the comments. So these lines
Inverse = %calculate the inverse of a matrix with the inv function
Result1 = %calculate Inverse times A
Result2 = %calculate A times Inverse
should be this instead
% Inverse = calculate the inverse of a matrix with the inv function
% Result1 = calculate Inverse times A
% Result2 = calculate A times Inverse
0 comentarios
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!