% Script inverse.m A = [ [1,2,-3,4]; [5,6,-7,8]; [9,8,7,6]; [3,4,5,4] ]; Acopy = A; [A,r] = gauss(A); x1 = gaussSolve(A, r, [1,0,0,0]); x2 = gaussSolve(A, r, [0,1,0,0]); x3 = gaussSolve(A, r, [0,0,1,0]); x4 = gaussSolve(A, r, [0,0,0,1]); Ainv = [x1, x2, x3, x4]; % check Acopy * Ainv Ainv * Acopy