561
|
1 function p = polyreduce(p) |
904
|
2 |
|
3 # polyreduce(c) |
|
4 # Reduces a polynomial coefficient vector to a minimum number of terms, |
|
5 # i.e. it strips off any leading zeros. |
561
|
6 # |
904
|
7 # SEE ALSO: poly, roots, conv, deconv, residue, filter, polyval, polyvalm, |
|
8 # polyderiv, polyinteg |
561
|
9 |
|
10 # Author: |
|
11 # Tony Richardson |
|
12 # amr@mpl.ucsd.edu |
|
13 # June 1994 |
|
14 |
|
15 index = find(p==0); |
|
16 |
|
17 index = find(index == 1:length(index)); |
|
18 |
|
19 if (length(index) == 0) |
|
20 return; |
|
21 endif |
|
22 |
|
23 if(length(p)>1) |
|
24 p = p(index(length(index))+1:length(p)); |
|
25 endif |
|
26 |
|
27 if(length(p)==0) |
|
28 p = 0; |
|
29 endif |
|
30 endfunction |