Skip to content

Create matlab's equivalent to bandwidth. #690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kreijstal opened this issue Jan 9, 2022 · 4 comments
Closed

Create matlab's equivalent to bandwidth. #690

Kreijstal opened this issue Jan 9, 2022 · 4 comments

Comments

@Kreijstal
Copy link

Is it possible to create matlab's equivalent to bandwidth in control?
https://www.mathworks.com/help/control/ref/lti.bandwidth.html
or are there any alternatives available?

@murrayrm
Copy link
Member

murrayrm commented Jan 9, 2022

Definitely possible, although this can also be done with the output from bode_plot and the Numpy argmin function, I suspect.

If you (or someone) want to contribute code to do this, we can put it either in the main package or in the MATLAB compatibility module.

@Kreijstal
Copy link
Author

Kreijstal commented Jan 10, 2022

Here is roughly how I solved it for me, I don't have time for providing a pull request, but maybe someone writing the pull request can get inspired.

import scipy
import numpy as np
def bandwidth(sys,dbgain=-3):
  result=scipy.optimize.root(lambda s:control.matlab.freqresp(sys,s)[0][0]-control.matlab.dcgain(sys)*10**(dbgain/20),1)
  if result.success:
    return np.abs(result.x)[0]
  else:
    raise Exception(result.message)

@roryyorke
Copy link
Contributor

Looks like merged #889 closes this?

@Kreijstal
Copy link
Author

I have not used control in years, but I am happy it got solved

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

No branches or pull requests

3 participants