% Section 7 % Sample solution to calculate determinant of 3-by-3 matrix function result = myDeterminant(x) % result is the determinant of matrix x. % a1, a2, a3 are the minor matrices. a1(1,1) = x(2,2); a1(1,2) = x(2,3); a1(2,1) = x(3,2); a1(2,2) = x(3,3); a2(1,1) = x(2,1); a2(1,2) = x(2,3); a2(2,1) = x(3,1); a2(2,2) = x(3,3); a3(1,1) = x(2,1); a3(1,2) = x(2,2); a3(2,1) = x(3,1); a3(2,2) = x(3,2); result = x(1,1)*det(a1) - x(2,2)*det(a2) + x(3,3)*det(a3); % Alternate sample solution to calculate determinant of 3-by-3 matrix function output = myDeterminant(x) % output is the determinant of matrix x. output= x(1,1)*det(x(2:3,2:3)) ... - x(1,2)*det(x(2:3,[1 3])) ... + x(1,3)*det(x(2:3,1:2));