# Modeling system with piecewise constant control input

**URL:** <https://discourse.julialang.org/t/modeling-system-with-piecewise-constant-control-input/86057>\
**Category:** Modelling & Simulations\
**Tags:** question, diffeq\
**Created:** [August 20, 2022, 8:23am UTC](https://discourse.julialang.org/t/modeling-system-with-piecewise-constant-control-input/86057 "2022-08-20T08:23:06Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [August 20, 2022, 10:14am UTC](https://discourse.julialang.org/t/modeling-system-with-piecewise-constant-control-input/86057/5 "2022-08-20T10:14:05Z")

</div>

What kind of variable is your input? What is its role in your problem? I dare to guess (based on some other private discussion we had) that it is actually a control variable.

If I am right, then most often than not this control variable (some might call it manipulated variable) will be periodically produced by a discrete-time (computer) controller. The variable will then be piecewise constant and the simulation should capture this. There was already some discussion of this here:

> [@Mixing time-discrete and time-continuous systems in a simulation](https://discourse.julialang.org/t/mixing-time-discrete-and-time-continuous-systems-in-a-simulation/74277/3):
>
> Thank you for the quick response! Ah, I’m looking forward when this is implemented in ModelingToolkit; then I can hopefully drop MATLAB/Simulink for good.

> [@DiffEqs: Hybrid (continuous+discrete) system / periodic callback](https://discourse.julialang.org/t/diffeqs-hybrid-continuous-discrete-system-periodic-callback/23791/39):
>
> Sorry to resurrect an old topic. I just want to register my findings. I use DEDataVector a lot. In my case, solutions like extending the state with dummy variables would not be feasible, and that’s why: The main project here using this framework is a satellite simulator. In this case, we use DiscreteCallback to simulate the full attitude control software. We have more than 2,000 parameters, including variables that are boolean, integers, etc. The idea is that we modeled all the embedded softwa…

But I am sorry in case this is off topic.

---

_[View the full topic](https://discourse.julialang.org/t/modeling-system-with-piecewise-constant-control-input/86057)._
