Skip to content

Fix for bug in margin.py #58

Description

@callawaycass

Calling margin() or stability_margins() with (mag, phase, omega) form yields incorrect result. I found that the issue is in line 125 of margin.py, where it calls frdata.FRD to create the system:

sys = frdata.FRD(mag*np.exp((1j/360.)*phase), omega, smooth=True)

The phase angle conversion is incorrect. Changing this line to:

sys = frdata.FRD(mag*np.exp(1j*phase*np.pi/180), omega, smooth=True)

yields the correct result. Also, it may be good to clearly indicate that the magnitude data in this form must be absolute magnitude, not dB, and that the phase must be in degrees. The frequency can be either Hz or rad/s... the output frequency is in the same units as whatever you put in (Matlab's documentation has a similar note).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions