How can a Simulink State Space block state be periodically reset?

10 views (last 30 days)
In Simulink, can a State Space block's states be periodically reset, ie not just set on startup?
If not, what alternative is there to accomplish the same thing?
I'm looking to periodically (every T sec) reset the states of a State Space block (say, called "R" for reset), and reset them to a set of passed parameters (states); ie not static constants from the workspace that only act on sim initialization.
These passed reset-value states might come from another continuously-run State Space block (say, the block is "C" for continuous, and its states are the "Good" states), as one example...
At each n*T tick i'd look to update the states of R to the Good states, so that R somewhat matches C as time goes on. Yes, these updates could lead to discontinuous behavior from R, but that's okay.
The question is, how can I periodically update R's states?
  7 Comments
Sam Chak
Sam Chak on 25 Feb 2024
Hey @John, I can only see the programmatic state-resettable approach being useful when both systems R and C are asymptotically stable. Plus, the designer doesn't necessarily need to be mathematically skilled with this approach.
John
John on 8 Mar 2024
Thanks @Sam Chak for your ideas :)
The two systems will be close, so it wouldn't be like your example that doesn't address the underlying examples. But, the update period will be short enough that even if the dynamics aren't addressed, the divergence won't be large.
So this could be a way to go. I'll check out Paul's thoughts as well now, and then see what might work best for this specific situation. Thanks for your examples!

Sign in to comment.

Answers (1)

Paul
Paul on 24 Feb 2024
Edited: Paul on 24 Feb 2024
i think you'll have to use an Integrator and other native blocks to implement
xdot = A*x + B*u
y = C*x + D*u
Use the external initial condition option and the external reset option to reset the integrator states to the signal on the initial condition line based on whatever your reset logic is. The signal on the IC line should be the IC of the integrator at t = 0 and then the values to reset to at the resets as t moves forward.
Make sure to have appropriate solver settings (solver type, zero crossing detection).
Here's an example that resets the state of the integrator to 1 every time the sine wave crosses zero in either direction, i.e., every pi seconds.
  3 Comments
John
John on 8 Mar 2024
Interesting on both -- thanks @Paul.
Regarding "it may be of interest that the states of State Space block and can be reset to the Initial Conditions block parameter if the state space block is inside a Resettable Subsystem", is there a way to make state space block intitial conditions a variable, vs constants?
"i think you'll have to use an Integrator and other native blocks to implement"
Good point -- this may be a good solution. I'll look into it and see which approach makes the most sense for this application.
Paul
Paul on 8 Mar 2024
Just like any other block parameter, the Initial Conditions parameter of the State Space block can be any expression that evaluates to a valid value for the parameter, in this can a vector (of initial conditions). So you can use, for example, X0 as the parameter value, and then Simulink will evaluate X0 using the normal workspace hierarchy. I assume that works the same way at the resets if the State Space block resides inside a Resettable Subsystem, but I didn't test it.
Based on the context of this thread I assume you're considering putting the State Space block inside a Resettable Subsystem, using a variable, e.g., X0, for the Initial Condition, and then changing the value of X0 in the workspace in which it resides while the simuluation is running (or paused) before the next reset. I don't know if that's feasible, particularly if the new value of X0 isn't known until the time of the reset. It might be feasible, but I just don't know.

Sign in to comment.

Categories

Find more on General Applications in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!