function c = sym2poly(p)
%SYM2POLY Symbolic polynomial to polynomial coefficient vector.
%	SYM2POLY(p) returns the vector of coefficients of the symbolic
%	polynomial p.
%
%	Example:
%	    sym2poly('x^3 - 2*x - 5') = [1 0 -2 -5].
%
%	See also POLY2SYM, POLYVAL.

%	Copyright (c) 1993-95 by The MathWorks, Inc.
%	$Revision: 1.9 $  $Date: 1995/03/07 15:07:04 $

x = symvar(p);
maple(['ans := ' p]);
c = maple(['seq(coeff(",' x ',k),k=0..degree(ans))']);
if isempty(maple(['ans := indets([' c '])']))
   c = fliplr(eval(['[' c ']']));
else
   error('Argument must contain exactly one symbolic variable.')
end
