Code covered by the BSD License  

Highlights from
Analog Filter Design Toolbox

image thumbnail
from Analog Filter Design Toolbox by James Squire
GUI to design and simulate active (opamp) LP and HP Bessel, Butter, Cheby, and Elliptic filters.

MenuAnalyzePoleZeroPlot
function MenuAnalyzePoleZeroPlot
% MenuAnalyzePoleZeroPlot is a subfile of the AnalogFilter GUI collection
%
% James C. Squire, 2002
% Assistant Professor, Virginia Military Institute
% ver 1.0

% MenuAnalyzePoleZeroPlot opens a plot of the current filter's poles and zeros

global strFilterObject

% find the roots
strFilterObject=Utility_zpk(strFilterObject);
p = strFilterObject.vPoles;
z = strFilterObject.vZeros;
k1 = strFilterObject.fK1;
p1 = strFilterObject.vPoles1;
z1 = strFilterObject.vZeros1;

sTitle=strFilterObject.sTitle;

% set up plot
figure('menubar','none','toolbar','none','Name',sTitle,'Numbertitle','off')

% plot it
if isempty(k1)
    if ~isempty(z)
        plot(real(p),imag(p),'kx',real(z),imag(z),'ko','markersize',15,'linewidth',1.5)
    else
        plot(real(p),imag(p),'kx','markersize',15,'linewidth',1.5)
    end
else
    if ~isempty(z)
        plot(real(p),imag(p),'kx',real(z),imag(z),'ko',real(p1),imag(p1),'bx',real(z1),imag(z1),'bo','markersize',15,'linewidth',1.5)
    else
        plot(real(p),imag(p),'kx',real(p1),imag(p1),'bx','markersize',15,'linewidth',1.5)
    end
end
axis('equal');

% add labels and origin lines
xlabel('Real Axis'), ylabel('Imaginary Axis')
hold on
axlim=axis;
plot([0 0],axlim(3:4),'g:',axlim(1:2),[0 0],'g:','linewidth',1)
axlim=axis;
axis(axlim*(1+eps)) % weird Matlab bug will sometimes cut off one of the X's marking the poles as being outside the plot area (perhaps because of the size of the marker)
plot([0 0],axlim(3:4),'g:',axlim(1:2),[0 0],'g:','linewidth',1) % weird Matlab bug requires a double-plot sometimes
title(strFilterObject.sTitle)
% add legend if needed
if ~isempty(k1)
    h=plot(0,0,'k',0,0,'b','linewidth',10);  % get a handle to a black and blue line
    legend(h,'ideal components','actual R/C values')
end
figure(gcf)



Contact us at files@mathworks.com