Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

control.margin() gives wrong result #465

Closed
Labels
@AchmadFathoni

Description

@AchmadFathoni

Control version : 0.8.3

import controlimport matplotlib.pyplot as pltGp = control.tf([2],[1,3,2,0])Gz = control.c2d(Gp,0.05)mag, phase, omega = control.bode(Gz)print(control.margin(Gz))print(control.margin([mag, phase, omega]))plt.grid()plt.show()

The example above prints

(31.505480557979414, inf, 3.7736323313549196, nan)(inf, 177.40890111291884, nan, 0.749329697586152)

The correct value can be obtained with this code

import control as ct import numpy as npimport matplotlib.pyplot as pltimport mathfrom scipy import interpolateGp = ct.tf([2],[1,3,2,0])Gz = ct.c2d(Gp, 0.05)mag, phase, omega = ct.bode(Gz)p_w = interpolate.interp1d(phase, omega)p_m = interpolate.interp1d(phase, mag)print("Gain margin %.3f at %.3f rad/s"%(1/p_m(-np.pi), p_w(-np.pi)))m_w = interpolate.interp1d(mag, omega)m_p = interpolate.interp1d(mag, phase)print("Phase margin %.3f\N{DEGREE SIGN} at %.3f rad/s"%(math.degrees(m_p(1)+np.pi), m_w(1)))

Which prints

Gain margin 2.771 at 1.367 rad/sPhase margin 31.394° at 0.753 rad/s

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp