GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Phase shift in bode plot · Issue #467 · python-control/python-control

Phase shift in bode plot #467

New issue
Copy link
New issue
Copy link
Closed
Closed
Phase shift in bode plot#467
Copy link
Assignees
murrayrm
Milestone
0.9.1

Description

@SebastienDeriaz
SebastienDeriaz
opened on Nov 10, 2020
Issue body actions

Given the transfer function
G = 1/s^3
We should see a constant negative phase of -270°, which is confirmed in matlab

image

However, both control.bode and control.matlab.bode give 90° instead of -270°. Although technically the same value, it does get confusing.

import control
import control.matlab
s = control.tf('s')

G = 1/s**3

control.bode(G);

image

control.matlab.bode(G);

image

What i've tried so far

  • using different transfer functions (1/s^4 or 1/s^2 * 1/(s+10))
  • specifying "omega" with a frequency range (as suggested here : https://ch.mathworks.com/matlabcentral/answers/99531-why-is-the-phase-that-is-returned-by-the-bode-function-wrapping-in-the-control-system-toolbox-5-1-r )
  • extending the "omega" range

Is it possible to get the "absolute" phase of the transfer function ? If not, i would suggest that control.matlab.bode be corrected as to reflect the behavior of matlab's bode

Thanks for your help !

Activity

  1. SebastienDeriaz commented on Nov 10, 2020

    @SebastienDeriaz
    SebastienDeriaz
    on Nov 10, 2020
    Author
    More actions

    My (limited) understanding of the function is that bode uses freqresp which uses evalfr and then numpy.angle. Since evalfr returns a complex number it isn't directly possible to get the "absolute" angle so the issue i'm reporting seems to require a dedicated code to determine a "reference phase" of some sort.
    My excuses for my current level of python (or gitHub) doesn't lead me much further than that

  2. bnavigator commented on Nov 10, 2020

    @bnavigator
    bnavigator
    on Nov 10, 2020
    Contributor
    More actions

    Thanks, for bringing this up.

    Related issue: #388

    My excuses for my current level of python (or gitHub) doesn't lead me much further than that

    You are nevertheless very welcome to practice your Python and GitHub skills by trying to fix the issue and submitting a pull request 🧑‍🎓

  3. ilayn commented on Nov 10, 2020

    @ilayn
    ilayn
    on Nov 10, 2020
    More actions

    The phase correction is only possible when you have the pole-zero structure and the behavior w->0, so you have to compute the initial phase to get the right amount of shift which is typically done with a decision of adding a minus sign attached to the atan2 computation.

    When you supply a custom frequency grid then it is trickier to snap to the correct phase since then you have to evaluate more stuff to get to that grid from the pole-zero structure (if there is any, say FRD objects don't have it).

    Reacted by Juan Pablo Pierini
  4. murrayrm
    added this to the 0.9.x milestone on Dec 26, 2020
  5. murrayrm
    self-assigned this
    on Dec 29, 2020
  6. murrayrm
    added
    PR pending
    on Jan 2, 2021
  7. bnavigator commented on Jan 3, 2021

    @bnavigator
    bnavigator
    on Jan 3, 2021
    Contributor
    More actions

    Resolved in #494. If you think this is not solved, please reopen.

  8. bnavigator
    closed this as completedon Jan 3, 2021
  9. bnavigator
    removed
    PR pending
    on Jan 3, 2021
  10. Juan-Gg commented on Aug 9, 2023

    @Juan-Gg
    Juan-Gg
    on Aug 9, 2023
    More actions

    It seems to work with poles, but it does not with zeros.

    For a single zero a constant phase of 90º would be expected, it gives -270º instead.

    from matplotlib import pyplot as plt 
    from control.matlab import *  # MATLAB-like functions
    
    %matplotlib widget
    s = tf('s')
    G = (s)
    plt.figure()
    bode(G, wrap_phase = False)
    plt.show()
    

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @murrayrm
    murrayrm

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    • 0.9.1

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.