Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

An Elegant way of plotting the Pole-Zero diagram

344 views
Skip to first unread message

bk20...@gmail.com

unread,
May 18, 2008, 7:35:20 AM5/18/08
to
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

Bob Hanlon

unread,
May 19, 2008, 6:23:12 AM5/19/08
to
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

Szabolcs Horvát

unread,
May 19, 2008, 6:25:33 AM5/19/08
to
bk20...@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[].

Here are two functions for those symbols:

zero[pt_, size_: 10] := Circle[pt, Offset[size/2 {1, 1}]]

pole[pt_, size_: 10] :=
Line[Map[Offset[size/2 #,
pt] &, {{{1, 1}, {-1, -1}}, {{-1, 1}, {1, -1}}}, {2}]]

The size is specified in printer's points, i.e. it stays constant while
resizing the plot.

Jens-Peer Kuska

unread,
May 19, 2008, 6:47:31 AM5/19/08
to
Hi,

and

poles = {0.45 + I*0.45, -0.45 - I*0.45};
zeros = {1, -1};

Graphics[{{Dashing[Tiny], GrayLevel[0.25],
Circle[{0, 0}, 1]}, {RGBColor[1, 0, 0],
Text["\[Times]", {Re[#], Im[#]}] & /@ poles,
Text["\[EmptyCircle]", {Re[#], Im[#]}] & /@ zeros}}, Axes -> True,
AspectRatio -> 1
]

does not help ?

Regards
Jens

0 new messages