# Using MATLAB to implement Cramer's Rule

by .....
Tags: cramer, implement, matlab, rule
 P: 341 Using MATLAB to implement Cramer's Rule here is a row/column selector the rest is looping and det function. r and c is the number of row/column that you cancel of the matrix A, Ac is the result that you get. function [Ac] = cancelrowcol(A,r,c) [n,m] = size(A); % Shortcut to upper left and lower right corner... if ((r == 1) && (c ==1)) Ac = sel(A,2:n,2:m); return elseif ((r == n) && (c == m)) Ac = sel(A,1:n-1,1:m-1); return % Otherwise else Atemp = vertcat(sel(A,1:(r-1),1:m),sel(A,(r+1):n,1:m)); Ac = horzcat(sel(Atemp,1:(r-1),1:(c-1)),sel(Atemp,1:(r-1),(c+1:m))); end end