## Copyright (C) 1999 Paul Kienzle ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## usage: zplane(b [, a]) or zplane(z [, p]) ## ## Plot the poles and zeros. If the arguments are row vectors then they ## represent filter coefficients (numerator polynomial b and denominator ## polynomial a), but if they are column vectors or matrices then they ## represent poles and zeros. ## ## This is a horrid interface, but I didn't choose it; better would be ## to accept b,a or z,p,g like other functions. The saving grace is ## that poly(x) always returns a row vector and roots(x) always returns ## a column vector, so it is usually right. You must only be careful ## when you are creating filters by hand. ## ## Note that due to the nature of the roots() function, poles and zeros ## may be displayed as occurring around a circle rather than at a single ## point. ## ## The denominator a defaults to 1, and the poles p defaults to []. ## Either way no poles are displayed. ## TODO: Give some indication of the number of poles or zeros at a ## TODO: specific point. Affixing a x3 or something similar beside ## TODO: three identical poles for example would be useful. ## TODO: Use different colors for different columns of the matrix for ## TODO: compatibility if no other reason ## TODO: Consider a plot-like interface: ## TODO: zplane(x1,y1,fmt1,x2,y2,fmt2,...) ## TODO: with y_i or fmt_i optional as usual. This would allow ## TODO: legends and control over point colour and filters of ## TODO: different orders. function zplane(z, p) if (nargin < 1 || nargin > 2) usage("zplane(b [, a]) or zplane(z [, p])"); end if nargin < 2, p=[]; endif if columns(z)>1 || columns(p)>1 if rows(z)>1 || rows(p)>1 ## matrix form: columns are already zeros/poles else if isempty(z), z=1; endif if isempty(p), p=1; endif [z, p, g] = tf2zp(z, p); endif endif unwind_protect ##