How can a Simulink State Space block state be periodically reset?
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Paul
2024-2-24
编辑:Paul
2024-2-24
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 个评论
Paul
2024-3-8
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 General Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!