Re: An Elegant way of plotting the Pole-Zero diagram

• To: mathgroup at smc.vnet.net
• Subject: [mg88843] Re: [mg88833] An Elegant way of plotting the Pole-Zero diagram
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Mon, 19 May 2008 05:15:35 -0400 (EDT)

```Probably not "elegant"

The PlotMarkers for ListPlot doesn't work properly if the second list of points (zeros in this case) has only one point. For a single zero, the single point is duplicated to make the list seem to have two points.

Clear[poleZeroPlot];

The PlotMarkers for ListPlot doesn't work properly if the second list of points (zeros in this case) has only one point. For a single zero, the single point is duplicated to make the list seem to have two points.

poleZeroPlot[transferFunction_, s_: s] :=
Module[{denom, num, poles, zeros, pz, axStyle},
denom = Denominator[transferFunction];
num = Numerator[transferFunction];
poles = If[FreeQ[denom, s], {},
({Re[#], Im[#]} & /@ (s /.
Solve[denom == 0, s]))];
zeros = If[FreeQ[num, s], {},
({Re[#], Im[#]} & /@ (s /.
Solve[num == 0, s]))];
pz = Join[poles, zeros];
zeros = If[Length[zeros] == 1, Join[zeros, zeros], zeros];
axStyle = {Blue, AbsoluteDashing[{5, 5}]};
ListPlot[{poles, zeros} /. {} -> Sequence[],
PlotMarkers -> (Style[#, {Bold, Red, 16}] & /@
If[Length[poles] == 0, {"O"},
If[Length[zeros] == 0, {"X"},
{"X", "O"}]]),
Frame -> True,
Axes -> True,
AxesStyle -> {axStyle, axStyle},
PlotRange -> 1.1 {
{Min[-1, Min[pz[[All, 1]]]],
Max[1, Max[pz[[All, 1]]]]},
{Min[-1, Min[pz[[All, 2]]]],
Max[1, Max[pz[[All, 2]]]]}},
Epilog -> Append[axStyle,
Circle[{0, 0}, 1]],
AspectRatio -> Automatic]]

poleZeroPlot[(s + 2)/(s^2 + 1/4)]

poleZeroPlot[(s^2 + 1/4)/(s + 2)]

poleZeroPlot[s^2 + 1/4]

poleZeroPlot[1/(z^2 + 1/4), z]

Bob Hanlon

---- bk2005usa at gmail.com wrote:
> Hi to All:
>
> Would anyone care to provide an elegant way of plotting the pole-zero
> diagram of a transfer function H[s], using the conventional symbols,
> namely, "x" for poles and "0" for zeros.  Mathematica does not have a
> built-in function to draw those symbols---like "Point[] and
> PointSize[].
> Your help will be appreciated
> Lemiel
>

```

• Prev by Date: Re: Re: NthSubset function of Combinatorica package