function S=reducmat(A,n,m);
%REDUCMAT is used to delete the nth row and the mth column from A to get
%  the smaller matrix S.  
%
%  INPUTS: 
%    (i) A = matrix to be reduced
%   (ii) n = row to be deleted;  if n=0, no row is deleted.
%  (iii) m = column to be deleted;  if m=0, no column is deleted.
% 
%  OUTPUTS:
%    (i) S = A with the nth row and mth column removed
%
[p,q]=size(A);
if (p<n | q<m);
  error('The row or column to be deleted exceeds the dimensions of your matrix')
else;
  P=eye(p);
  Q=eye(q);
  if n~=0; P=[P(1:n-1,:); P(n+1:p,:)]; end;
  if m~=0; Q=[Q(:,1:m-1)  Q(:,m+1:q)]; end;
  S=P*A*Q;
end;
