What are continuous and discrete states in Simulink?

I see references in the Simulink documentation to continuous and discrete states, for example: Does the block need to model continuous or discrete state behavior. Is this the same thing as "Does the block need to solve for time variation of some quantity, either at continuous or fixed time steps?" If not, please define what a state is in Simulink.

 Accepted Answer

In my own words, a crude word to use in place of "state" is "memory". A state adds memory to a system in such as way that the output at a given time depends not only on its current input, but also on its previous inputs. There is also a more formal explanation about states here:
Discrete states can be thought purely as internal memory - for example a Unit Delay block has one discrete state, and it's output is computed based on two methods: Outputs and Update, which may be written as follows (u=input, x=state, y=output):
Outputs()
y = x;
Update()
x = u;
Here, the Simulink Engine never reads the discrete states, it only manages the memory allocation/de-allocation for the states. The delay is caused due to the fact that Update() runs after Output(), which means that the current "u" is only read into "y" at the next time-step when Output() runs again.
With continuous states however, Simulink asks the block to provide a derivative (dx/dt) of the state in the Derivatives() method and uses its ODE solver to compute the integral of dx/dt to obtain 'x'. This 'x' can then be accessed in the Outputs() function. For example, to implement an Integrator block, we might write:
Outputs()
y = x;
Derivatives()
x_dot = u;
Here, the Simulink Engine reads x_dot and computes x for use in Outputs.
In both cases, at t=0, the value of 'x' is whatever what provided as the Initial Condition by the block.

7 Comments

I like your answer Kaustubha!
A discrete state is stored at one time steps and retrieved later. The Simulink engine does nothing except storing the value.
A continuous state is integrated by the Simulink solver. You give "dx/dt" to the solver and the solver gives you back "x".
Very nice and simplified explaination.
Thanks again! The linked information is found in the section 'How Simulink Works' of the Simulink User's Guide, which can be obtained in PDF form here, http://www.mathworks.com/help/pdf_doc/allpdf.html , which I find easier to read than the online version. I am mentioning this because the whole section was worth reading, as a beginner.
@Kaustubha Govind, that's a great explanation. Can that be translated to Matlab System Objects? I.e., is there a way to describe the differentials and let Simulink solve the ODE instead of using Forward Euler or whatever explicitely in the stepImpl function with discrete states?
This is an important question. Can someone from the Mathworks team please try to answer it?

Sign in to comment.

More Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Products

Asked:

K E
on 26 Apr 2012

Commented:

on 7 May 2024

Community Treasure Hunt

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

Start Hunting!