function boo = isDiagonalPoly(P,Index)
% Determine if off-diagonal polynomials in cell array P are 0 or empty.
%
% isDiagonalPoly(P) determines if square polynomial matrix P is diagonal.

%   Author(s): Rajiv Singh
%   Copyright 2009-2010 The MathWorks, Inc.

boo = true;
L = size(P,1);
if L<=1, return, end

if nargin<2
   OffDiag = setdiff(1:L^2,(1:L+1:L^2));
else
   % test setdiff(1:L,Index) rows/cols
   SubM = reshape(1:L^2,L,L);
   SubM = SubM(Index,Index);
   OffDiag = setdiff(1:L^2,[1:L+1:L^2,SubM(:)']);
end

for ct = OffDiag
   if ~isempty(P{ct}) && ~isequal(P{ct},0)
      boo = false; return;
   end
end
