function CramerExample % Coded by Nigel F. Reuel on 10.18.16 % This code shows how to solve a SMALL system of equations using cramer's % rule % A = [10 2 -1; -3 -5 2; 1 1 6]; B = [27; -61.5; -21.5]; % D = det(A); M1 = [B A(:,2:3)]; x1 = det(M1)/D % M2 = [A(:,1) B A(:,3)]; x2 = det(M2)/D % M3 = [A(:,1:2) B]; x3 = det(M3)/D % x = A\B end