Mercurial > octave-nkf
diff scripts/polynomial/polyreduce.m @ 561:e79ff1f4df3c
[project @ 1994-07-25 22:32:08 by jwe]
Initial revision
author | jwe |
---|---|
date | Mon, 25 Jul 1994 22:32:08 +0000 |
parents | |
children | 3470f1e25a79 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/polynomial/polyreduce.m Mon Jul 25 22:32:08 1994 +0000 @@ -0,0 +1,29 @@ +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