Skip to content

Bode plots use Hz instead of rad/sec in MATLAB compatibility mode #373

Description

@paulvicioso

Hi everyone,

When I try the bode function from the control.matlab library to plot the Bode of a simple function (H(s)=1/(s+1)) I'm getting the wrong angular frequencies (shifted one decade). In other words, the break frequency is at 0.1 rad/s instead of 1.0 rad/s (see image). I'm not sure if this is an issue or I'm just doing something wrong. Could you please help me with this problem.

My system is a macOS Catalina 10.15.3 and I'm using Python 3.7.5.

import numpy as np
import control.matlab as ml
import matplotlib.pyplot as plt

num = np.array([1])
den = np.array([1, 1])

G = ml.tf(num, den)

print(G)

mag, phase, freq = ml.bode(G)
plt.show()

Bode_plot

Thank you

Activity

  1. murrayrm commented on Feb 17, 2020

    @murrayrm
    Member

    The units for frequency are in Hertz, not rad/sec. 1 rad/sec = 1/(2*pi) Hz = 0.16, which is where the breakpoint is (easiest to see as the point where the phase crosses 45 degrees).

    It looks like this is a bug in the way that defaults are set up for the MATLAB compatibility module, which sets bode.Hz = True. Can't remember if this has always been that way or whether the bug was introduced when the new config module was set up.

    Quick fix: use bode(..., Hz=False).

    Proper fix: we should change the default settings to match MATLAB.

  2. paulvicioso commented on Feb 18, 2020

    @paulvicioso
    Author

    Thank you, that solved the problem.

    I did not check that the frequencies were in Hz, I just made the assumption that everything was the same as in MATLAB.

  3. changed the title [-]Bode Function produces wrong angular frequencies[/-] [+]SOLVED: Bode Function produces wrong angular frequencies[/+] on Feb 18, 2020
  4. self-assigned this
    on Feb 18, 2020
  5. changed the title [-]SOLVED: Bode Function produces wrong angular frequencies[/-] [+]Bode plots use Hz instead of rad/sec in MATLAB compatibility mode[/+] on Feb 18, 2020
  6. added this to the 0.8.4 milestone on Mar 21, 2020
  7. linked a pull request that will close this issueFix plot issues #382on Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions