comparison scripts/polynomial/polyderiv.m @ 1025:f558749713f1

[project @ 1995-01-11 20:52:10 by jwe]
author jwe
date Wed, 11 Jan 1995 20:52:10 +0000
parents 3470f1e25a79
children 611d403c7f3d
comparison
equal deleted inserted replaced
1024:56520a75b5b3 1025:f558749713f1
1 function p = polyderiv(p) 1 # Copyright (C) 1995 John W. Eaton
2 #
3 # This file is part of Octave.
4 #
5 # Octave is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
8 # later version.
9 #
10 # Octave is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Octave; see the file COPYING. If not, write to the Free
17 # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
2 18
3 # polyderiv(c) 19 function p = polyderiv (p)
20
21 # usage: polyderiv (p)
22 #
4 # Returns the coefficients of the derivative of the polynomial whose 23 # Returns the coefficients of the derivative of the polynomial whose
5 # coefficients are given by vector c. 24 # coefficients are given by vector p.
6 # 25 #
7 # SEE ALSO: poly, polyinteg, polyreduce, roots, conv, deconv, residue, 26 # SEE ALSO: poly, polyinteg, polyreduce, roots, conv, deconv, residue,
8 # filter, polyval, polyvalm 27 # filter, polyval, polyvalm
9 28
10 # Author: 29 # Written by Tony Richardson (amr@mpl.ucsd.edu) June 1994.
11 # Tony Richardson
12 # amr@mpl.ucsd.edu
13 # June 1994
14 30
15 if(nargin != 1) 31 if (nargin != 1)
16 usage ("polyderiv(vector)"); 32 usage ("polyderiv (vector)");
17 endif 33 endif
18 34
19 if(is_matrix(p)) 35 if (is_matrix (p))
20 error("argument must be a vector"); 36 error ("argument must be a vector");
21 endif 37 endif
22 38
23 lp = length(p); 39 lp = length (p);
24 if(lp == 1) 40 if (lp == 1)
25 p = 0; 41 p = 0;
26 return; 42 return;
27 elseif (lp == 0) 43 elseif (lp == 0)
28 p = []; 44 p = [];
29 return; 45 return;
30 end 46 end
31 47
32 p = p(1:(lp-1)) .* [(lp-1):-1:1]; 48 p = p (1:(lp-1)) .* [(lp-1):-1:1];
33 49
34 endfunction 50 endfunction