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
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
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.
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