1
$\begingroup$
* Spyder version: 5.4.3  (conda)
* Python version: 3.10.9 64-bit
* Qt version: 5.15.2
* PyQt5 version: 5.15.7
* Operating System: Linux 5.19.0-43-generic
* scipy: 1.10.0

I'm attempting to replicate the control system example in this video starting at about 17:00.

sys = ct.tf([3.553e-15, -.1642, -.1243, -.00161, 9.121e-17],
            [1, 1.825, 2.941, .03508, .01522, -1.245e-15])

ct.nyquist(sys)

Python generates the Nyquist plot but not as nicely as MATLAB and with the following warnings

ct.nyquist(sys)
/home/hugh/anaconda3/lib/python3.10/site-packages/scipy/signal/_filter_design.py:1746: BadCoefficients: Badly conditioned filter coefficients (numerator): the results may be meaningless
  warnings.warn("Badly conditioned filter coefficients (numerator): the "
/tmp/ipykernel_803667/2969248940.py:1: UserWarning: indented contour may miss closed loop pole; consider reducing indent_radius to below 3e-15
  ct.nyquist(sys)

This is my first stab at using Python for this sort of work and at the moment my confidence is low. Is there some precursor or configuration or anything else that I'm overlooking?

$\endgroup$
2
  • 1
    $\begingroup$ I think the warning says it already what is the matter. Scipy version? github.com/scipy/scipy/issues/2980 $\endgroup$
    – Juha P
    Jun 13 at 3:51
  • $\begingroup$ scipy version 1.10.0 $\endgroup$
    – yahugh
    Jun 13 at 13:39

1 Answer 1

1
$\begingroup$

As Juha says: the error message tells you what to do.

import numpy as np
import control as ct

sys = ct.tf([3.553e-15, -.1642, -.1243, -.00161, 9.121e-17],
            [1, 1.825, 2.941, .03508, .01522, -1.245e-15])
0
ct.nyquist(sys, indent_radius=1e-16, omega=np.arange(0,100,0.0001))

Note I've also included a finer resolution of the frequencies used to make the plot look closer to what matlab in the video is generating.

Nyquist plot of system.

$\endgroup$
2
  • 1
    $\begingroup$ Ah-hah! I didn't understand the previous comment about the indent radius. Thank you for providing this example. Answer accepted. $\endgroup$
    – yahugh
    Jun 14 at 17:34
  • $\begingroup$ @yahugh You're welcome! $\endgroup$
    – Peter K.
    Jun 14 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.