# How can I model the integrator show the desired reset behaviour?

2 views (last 30 days)
DB on 9 Dec 2020
Commented: Paul on 10 Dec 2020
Hi,
I want to model continuous behaviour with its input depending on the discrete behaviour which should be changing per sample time. An example is shown below.
I have the discrete part modelled as shown below.
Now I'm having trouble aligning the continuous part with this discrete part. There should be some reset coming from the discrete part. My current model is shown below with its combined scope plot for t=50.
Data:
I have initial value x0=[12;7.57] , gain A=[0.92 0.08 ; 0.15 0.85] , sample time ts=2 .
The pulse is period is sample time ts=2.
Paul on 10 Dec 2020
This model seems to be based on the assumption that for a discrete sequence x(k) governed by the difference equation
x(k+1) = A*x(k),x(0)=x0
that there is a continuous time solution between samples given by the equation
xdot(t) = A*x(t), t>=t(k), x(t(k)) = x(k)
The model posted above implements these two equations, but as you've noted it doesn't behave the way you expect. So the question is: why do you think these equations are correct for the process you want to model?
What would really be helpful is if you could explain the two light blue curves in the figure and how they relate to each other. I assume that the stair step curve is the solution to
x(k+1) = A*x(k) , x(0) = x0
But what is the other the light blue curve? Presumably it depends on the stair-step curve, but how? What is the mathematical relationship between them? Once that relationship is defined, it will be straightforward to model and simulate.
By the way, the posted model should be run with a much smaller step size to really see what's going on, maybe even use a variable step solver with a step size of 0.01

Fangjun Jiang on 9 Dec 2020
Edited: Fangjun Jiang on 9 Dec 2020
I can say for sure that this is not an Integrator setting issue. For the blue curve, it looks like the response of a highly damped second order system. The stair curve is the input. The controller has an initial condition and then is able to follow the input with a typical second order system response. For the red curve, it is not clear what is the input and what is the ouput, although it also looks like the response of a second order system with a overshoot.
DB on 9 Dec 2020
The red curve is one state modelled in discrete manner. I'm not sure what you mean with a damped second order system. This system is no physical system and has no damping and it is a first order system.

### Categories

Find more on General Applications in Help Center and File Exchange

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!