question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lti.evalfr and sys._evalfr have different behavior

See original GitHub issue

The evalfr function in the lti module expects a complex number and evaluates the system at that complex frequency. The method sys._evalfr, on the other hand, where sys is a transfer function or state space system, expects a real argument and multiplies it by j before evaluating the frequency response.

Is this dichotomy intentional?

  • matlab’s evalfr function expects a complex number, which seems like a more general-purpose solution. sys.freqresp expects real-valued omega arguments, making it perhaps a better interface for users
  • also, right now, only sys._evalfr correctly performs the z-plane transformation for discrete-time systems.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
sawyerbfullercommented, Jul 23, 2020

a __call__ method makes a lot of sense to me. It always struck me as odd how hard it is in matlab to find the frequency response of a transfer function – I didn’t know about evalfr until very recently.

Presumably a change moving evalfr to the matlab module and changing freqresp to frequency_response would entail a version or two in which those were wrappers accompanied by deprecation warnings?

1reaction
murrayrmcommented, Jul 23, 2020

We definitely need to remove the inconsistency, but I would encourage us to think more broadly and use a more Pythonic approach:

  • We can override the __call__ function so that P(s) will represent the “value” of a transfer function at a complex value s. This can replace the evalfr function. It should work for all LTI classes (including transfer functions, state space systems, FRD systems).

  • We can provide a class method frequency_response that takes a variety in input arguments representing a single frequency or list of frequencies. We could shorten this to freqresp, but I think that using the longer name is more consistent with other usage. We could also provide an “alias” for freqresp (both as a function and as a method?).

  • We can use the MATLAB compatibility module to provide functions that match MATLAB’s standard usage, but I don’t think we need to represent those in the main python-control module.

It would be great to get thoughts from others.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Evaluate system response at specific frequency - MATLAB evalfr
State-space model with 3 outputs, 3 inputs, and 3 states. Compute the frequency response of the system at 0.2 rad/second. Since sys is...
Read more >
master's thesis - DiVA
The complexity of multivariable systems, mainly the interactions between its elements, make it more difficult to deal with them than with scalar systems...
Read more >
Python Control Library Documentation
Linear time invariant (LTI) systems are represented in python-control in state space, transfer function, or frequency.
Read more >
Control System Toolbox User's Guide - UET Taxila
LTI Arrays of SS Models with Differing Numbers of States 4-23 ... frsp = evalfr(sys,f) evaluates the transfer function of the TF, SS,...
Read more >
Creation of linear time-invariant Models (LTI-Models)
Transfer behaviour. • Rational expression of Laplace variable s: ... LTI–Models are cell arrays with predefined model pro- ... frsp = evalfr(sys,f).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found