function d = gdeg(A,i,j) % GDEG Get degrees of polynomial elements of matrices in long format. % D = GDEG(A,i,j) returns the degrees of the (i,j) elements of % an m-by-n matrix of polynomials stored in an (m*n + 2)-by-(k+1) % matrix (long format). k is the highest degree of the polynomials % in A. If length(i) is M, LENGTH(j) is N then D will be an M-by-N % matrix containing the degrees of the elements of A. % D = GDEG(A,V) returns the degrees corresponding to the elements % in V. The resulting matrix of degrees is the same size as V. % % To specify all the elements along one dimension use ':'. % For instance, GDEG(A,2:3,':') returns the degrees of all the % elements in the second and third rows of A. % % See also GPET, GPEL % Written by Serge Tchikanda 06/13/96. % Last revised by Serge Tchikanda 06/17/96. if isempty(A) d = []; return end if nargin == 2 B = prtv(A,i); A = gpet(B,':'); else B = prtv(A,i,j); A = gpel(B,':',':'); end if isempty(B) return end [m,n] = size(A); for l = 1:m if all(A(l,:) == zeros(1,n)) d1(l) = -inf; else k = min(find(A(l,:))); d1(l) = n - k; end end d = zeros(psize(B)); d(:) = d1;