view scripts/polynomial/polyreduce.m @ 707:d7c4962ec7a0

[project @ 1994-09-16 13:50:20 by jwe]
author jwe
date Fri, 16 Sep 1994 13:53:18 +0000
parents e79ff1f4df3c
children 3470f1e25a79
line wrap: on
line source

function p = polyreduce(p)
#polyreduce(c)
#Reduces a polynomial coefficient vector to a minimum number of terms,
#i.e. it strips off any leading zeros.
#
#SEE ALSO: poly, roots, conv, deconv, residue, filter, polyval, polyvalm,
#          polyderiv, polyinteg

# Author:
#  Tony Richardson
#  amr@mpl.ucsd.edu
#  June 1994

  index = find(p==0);

  index = find(index == 1:length(index));

  if (length(index) == 0)
    return;
  endif

  if(length(p)>1)
    p = p(index(length(index))+1:length(p));
  endif

  if(length(p)==0)
    p = 0;
  endif
endfunction