Comments (6)
There is some discussion of the current approach in #812.
Something to try in python-control, MATLAB, and Octave is the following:
import control as ct
import matplotlib.pyplot as plt
sys = ct.tf(4, [1, 2, 10]) # example from MATLAB documentation
for dt in [0, 0.5, 0.2, 0.05]:
sys_dt = sys if dt == 0 else ct.c2d(sys, dt)
impulse_resp = ct.impulse_response(sys_dt)
plt.plot(impulse_resp.time, impulse_resp.outputs, label=f"{dt=}")
plt.legend()
plt.show()
The output in python-control is
This shows that the scaling makes sense when you think about the discrete time system being a sampled version of the continuous system (as described in #812).
from python-control.
Ah thank you! I was trying to find if this was already posted. I see now from a friend that MATLAB also scales it this way.
Regarding your comment on scaling, yes it totally makes sense in the mapping of an ODE from continuous time IF we were doing that. If I have a discrete time system then there is no further mapping and any connection to some continuous time system should already be in the scaling for that function. My example of an accumulator was exactly that: I included the
If it were to do the scaling as part of the c2d, that would make sense to me. But when I already have a discrete time system that I am modelling with its specific gain constants whatever they may be, it seems better (to me) that it represent what we would expect given the definition of the "unit sample response" as a discrete time impulse response.
(Should I be writing this under #812 and not here?)
from python-control.
(Should I be writing this under #812 and not here?)
#812 is merged, so better to keep the comments here.
from python-control.
Hi @cdboschen
This is typically tied to the common problem of defining the dirac function as a standalone unit sample function however that is not the definition of a unit impulse function. Hence, there is no right or wrong, it's just the definition. The discrete version is the Kronecker delta and both have only mathematical meaning under an integral or summation sign because they are technically generalized functions (or tempered distributions and so on depending on who you are hanging out with). They are not functions of time. And they should have the property
Because an impulse does not carry the value of 1 throughout the whole sample but when summed up (again only under summation sign) equals to unity mimicking the dirac delta
That's why it is not a proper function of [1, 0, 0, 0...]
which is exactly what it is.
Regarding your comment on scaling, yes it totally makes sense in the mapping of an ODE from continuous time IF we were doing that. If I have a discrete time system then there is no further mapping and any connection to some continuous time system should already be in the scaling for that function.
By mentioning that there is a continuous time system, we don't mean that we always start from a continuous one and derive all discrete-time models from. What I meant over #812, is that there is an "equivalence-class" between such systems that you can argue about an impulse response of all such systems which should result in the same behavior.
And we note that an impulse response is the integration of the step response.
I think you meant the other way around.
In control software generally you don't need to include dt
keyword. So if you want a discrete backwards euler integrator tf(1, [1, 0], dt=dt)
is sufficient and it will arrange things for you (I haven't checked it but should). Hence you don't need to add it yourself or if you want to model everything then you should keep track of
Note that if this is an integrator, then either it is your interpretation since you already have the information that it is linked to continuous time integrator or it is an information that you have beforehand. However suppose someone hands you a Tustin approximation of it
I am not suggesting that your argument is wrong or inaccurate but I am trying to portray how the convention is typically constructed.
from python-control.
Thank you @ilayn and I understand your points (and yes, you are correct, I meant the other way around). I really appreciate you taking the time to respond to my previous comments and helping me understand the broader perspective with the detail that you wrote, thank you!
I'm thinking of applications where I am simulating a discrete time system, and for a step and "impulse" response, I really want the result to be for the unit sample function (so the unit sample response specifically), and for my model to match the specific results I would get without "hidden" gain modifications (hence my examples). An "impulse response" does not really exist in discrete time so I would have expected the unit sample response from a con.impulse_response function.
To your point about "interpretation"; I am using the discrete time models as they are without concern of a mapping or equivalence to a continuous time model: my interpretation of the Tustin approximation of an integrator if that was handed to me as
So, that's my two cents, but I also get that there must be value in having the dt automatically scale when using the discrete time transfer functions to model continuous time systems. I can get to what I need without too much grief by simply always using dt=1 for my applications and scaling the time axis myself, and perhaps that is the best solution. (And I see that if it was changed to what I really want, then the inclusion of dt is trivial since it would only serve to scale the t that the function returns and have no other effect).
from python-control.
(Should I be writing this under #812 and not here?)
#812 is merged, so better to keep the comments here.
Ok understood I deleted my comment there to clean up.
from python-control.
Related Issues (20)
- How to convert finite step response model to state space representation? HOT 2
- Output calcs produce 0's at every other call HOT 2
- equations not showing up correctly in online docs HOT 2
- IndexError: index -1 is out of bounds for axis 0 with size 0 HOT 3
- TypeError: No support for MIMO without slycot HOT 4
- TimeResponseData.to_pandas() fails if there are no states in a NonlinearIOSystem HOT 1
- plotting example mimo system HOT 1
- Display Connection Matrix HOT 8
- (accidentally opened issue with garbage title) HOT 1
- Observability Gramian for discrete-time systems HOT 8
- `phase_plot` ODE function signature is not compatible with `solve_ivp` and `StateSpace.dynamics` HOT 2
- Strange nondeterministic issues when using `phase_plot` with `X`, `Y` and `X0` set HOT 1
- `control.mixsyn` hangs on M1 HOT 2
- documentation out of date HOT 1
- Wrong parameter name in documentation HOT 1
- Parallel system interconnection using `control.interconnect()` HOT 4
- Plotting nyquist plot from FrequencyResponseData fails HOT 3
- forced_response giving different output depending on Python and/or numpy version HOT 9
- inconsistent kwarg klist/kvect/gains in rlocus doc HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-control.