Michael Thomas Flanagan's Java Scientific LibraryPlotPoleZero Class:      Plotting Poles and Zeros

Last update: 12 August 2008
Main Page of Michael Thomas Flanagan Java Scientific Library

This class contains constructors and methods for calculating the poles and zeros of a transfer function, of the form, polynomial/polynomial, and ploting them on an s- or z-plane graph and writing the results to a text file. The poles and zeros, if known, may alternatively be entered directly.

import directive: import flanagan.plot.PlotPoleZero;
Related classes:
• PlotGraphThis class contains methods for plotting several curves on one set of x-y axes and displaying the graph in a window.
• Plotter A stand alone version of PlotGraph taking the data from a fixed format textfile.

### SUMMARY OF CONSTRUCTORS AND METHODS

 Constructors public void PlotPoleZero(ComplexPoly numerPoly, ComplexPoly denomPoly) public void PlotPoleZero(Complex[ ] numerCoeff, Complex[ ] denomCoeff) public void PlotPoleZero(double[ ] numerCoeff, double[] denomCoeff) public void PlotPoleZero() Set the numerator public void setNumerator(ComplexPoly numerPoly) public void setNumerator(Complex[ ] numerCoeff) public void setNumerator(double[ ] numerCoeff) Set the denominator public void setDenominator(ComplexPoly denomPoly) public void setDenominator(Complex[ ] denomCoeff) public void setDenominator(double[ ] denomCoeff) Set the zeros directly public void setZeros(Complex[] zeros) public void setZeros(double[] zeros) Set the poles directly public void setPoles(Complex[] poles) public void setPoles(double[] poles) Choose s-plane plot public void setS() Choose z-plane plot public void setZ() Set unit axes public void setUnitAxes() Set equal axes public void setEqualAxes() Set scale factor public void setScaleFactor() Find roots and plot graph public Complex[] pzPlot(String title) public Complex[] pzPlot()

### CONSTRUCTORS AND METHODS

CONSTRUCTORS
public void PlotPoleZero(ComplexPoly numerPoly, ComplexPoly denomPoly)
public void PlotPoleZero(Complex[ ] numerCoeff, Complex[ ] denomCoeff)
public void PlotPoleZero(double[ ] numerCoeff, double[ ] denomCoeff)
public void PlotPoleZero()
Usage:                      PlotPoleZero ppz = new PlotPoleZero(numerator, denominator);
Creates a new instance of PlotPoleZero for finding and plotting the poles and zeros of a transfer function of the form, polynomial/polynomial. The numerator (argument numerator) and denominator (argument denominator) may be entered as polynomials (type ComplexPoly) or as arrays of the coefficients of the polynomials. The array of coefficients may be complex (type Complex[]) or real (type double[]). The coefficients must be in the order corresponding to a polynomial of the form:
coeff[0] + coeff[1].s + coeff[2].s^2 + coeff[3].s^3 . . .
If no zeros are to be plotted the first argument, e.g. numerCoeff in the above usage, may be entered as null.
If no poles are to be plotted the second argument, e.g. denomCoeff in the above usage, may be entered as null.

Usage:                      PlotPoleZero ppz = new PlotPoleZero();
Creates a new instance of PlotPoleZero for finding and plotting the poles and/or zeros of a transfer function of the form, polynomial/polynomial, where the coefficients of the polynomials are to be entered using either setNumerator() and setDenominator() or setZeros() and setPoles() (below).

SET THE NUMERATOR
public void setNumerator(ComplexPoly numerPoly)
public void setNumerator(Complex[ ] numerCoeff)
public void setNumerator(double[ ] numerCoeff)
Usage:                      ppz.setNumerator(numerator);
Enters the numerator (argument numerator) of a transfer function of the form, polynomial/polynomial. The numerator may be entered as a polynomial (type ComplexPoly) or as an array of the coefficients of the polynomial. The array of coefficients may be complex (type Complex[]) or real (type double[]). The coefficients must be in the order corresponding to a polynomial of the form:
coeff[0] + coeff[1].s + coeff[2].s^2 + coeff[3].s^3 . . .

SET THE DENOMINATOR
public void setDenominator(ComplexPoly denomPoly)
public void setDenominator(Complex[ ] denomCoeff)
public void setDenominator(double[ ] denomCoeff)
Usage:                      ppz.setDenominator(denominator);
Enters the denominator (argument denominator) of a transfer function of the form, polynomial/polynomial. The denominator may be entered as a polynomial (type ComplexPoly) or as an array of the coefficients of the polynomial. The array of coefficients may be complex (type Complex[]) or real (type double[]). The coefficients must be in the order corresponding to a polynomial of the form:
coeff[0] + coeff[1].s + coeff[2].s^2 + coeff[3].s^3 . . .

ENTER THE ZEROS DIRECTLY
public void setZeros(Complex[ ] zeros)
public void setZeros(double[ ] zeros)
Usage:                      ppz.setZeros(zeros);
Enters the zeros directly. The zeros may be passed as an array of Complex or as an array of doubles.

ENTER THE POLES DIRECTLY
public void setPoles(Complex[ ] poles)
public void setPoles(double[ ] poles)
Usage:                      ppz.setPoles(poles);
Enters the poles directly. The poles may be passed as an array of Complex or as an array of doubles.

SET THE PLOT TO AN s-PLANE PLOT
public void setS()
Usage:                      ppz.setS();
• Sets the plot axes to those of an s-plane plot.
• Enables a check of the poles for system stability (result written to the output file PoleZeroOutput.txt)
See setZ (below) for choosing a z-plane plot.

SET THE PLOT TO AN z-PLANE PLOT
public void setZ()
Usage:                      ppz.setZ();
• Sets the plot axes to those of an z-plane plot.
• Draws a circle of unit radius on the z-plane plot if within the range of the axes.
• Enables a check of the poles for system stability (result written to the output file PoleZeroOutput.txt)
See setS (above) for choosing an s-plane plot.

SET THE AXES SPAN TO +1 TO -1
public void setUnitAxes()
Usage:                      ppz.setUnitAxes();
An optional method that:
• sets the span of the axes from −1 to +1 if the real and imaginary parts of all poles and zeros lie between −1 and +1.
• The span of the axes will be at least −1 to +1 if some poles and zeros lie outside this range but will also extend to include the points outside the −1 to +1 range.
• Draws a circle of unit radius on the z-plane plot.
See setEqualAxes (below) for setting axes to equal length.

SET THE AXES SPAN TO BE THE SAME FOR BOTH AXES
public void setEqualAxes()
Usage:                      ppz.setEqualAxes();
An optional method that:
• sets the span of the real and the imaganary axes to be the same, i.e. the starting point values and the end point values are identical for both the real and imaginary axes.
See setUnitAxes (above) for setting axes to unit circle diameter.

SET THE OVERALL SIZE OF THE PLOT
public void setScaleFactor()
Usage:                      ppz.setScaleFactor();
• This method should be called if a size of plot differeing from the default size is required. Setting the scale factor multiplies all default dimensions of the plot by that factor, e.g. entering a scale factor of 2.0 doubles all the default dimensions. Scale factors significantly less than 1.0 will cause crowding and overwriting of the text on the graph.

FIND ROOTS AND PLOT POLES AND ZEROS
public Complex[] pzPlot(String title)
public Complex[] pzPlot()
Usage:
ppz.pzPlot(title);
ppz.pzPlot();

or
zerosAndPoles = ppz.pzPlot(title);
zerosAndPoles = ppz.pzPlot();

• Finds the roots of both the numerator (zeros) and denominator (poles) unless the poles and/or zeros entered directly.
• Plots the poles and zeros on an s-plane or z-plane plot.
• Writes to a text file called PoleZeroOutput.txt the following:
• File header and type of plot, s, z or not known.
• Plot title if this was passed as a String to pzPlot() as its argument.
• Time and date the output file was created.
• Coefficients of the numerator polynomial.
• Coefficients of the denominator polynomial.
• Roots of the numerator polynomial (zeros).
• Roots of the denominator polynomial (poles).
• Radial distances (root moduli) if the plot is an z-plane plot (see setZ() below).
• Check for system stability if the plot is an s- or z-plane plot (see setS() and setZ(0 below)
• This method also returns the zeros and poles as a two dimensional Complex array, e.g. zerosAndPoles above; the zeros are contained in zerosAndPoles[0] and the poles in zerosAndPoles[1], null is returned for zerosAndPoles[0] if no zeros are present and null is returned for zerosAndPoles[1] if no poles are present.

### OTHER CLASSES USED BY THIS CLASS

This class uses the following classes in this library:

This page was prepared by Dr Michael Thomas Flanagan