MATLAB: How to use the state port of an integrator block in Simulink

blockdefinitionintegratorMATLABsimulinsimulinkstatestate portstates

Hi,
I want to use the state port for initial value of the integrator when it resets. However, I get an error message when I treat it like the output port by adding it with a sumblock to equal-sized state vector, by using a delay block on the signal. The following message occurs regularly:
State ports can only be used to break algebraic loops or to "hand-off" states between systems.
Use the output port rather than the state port of 'untitled/Integrator' as the source of the signal routed (either by direct or virtual connection) to 'untitled/Sample and Hold'
Can someone elaborate on what the state port exactly is? I don't really understand from what I can find about on the internet.

Best Answer

I don't really understand completely how your set-up looks like (can you post a screenshot maybe?) but I feel like instead of using the state port, you can use the output port to feed it back to the initial value port. The state port should only be used if you encounter algebraic loops when feeding the output port back to the reset or initial value input port. Standard procedure is to feed back the output port. The reason why you don't have the issue of an algebraic loop - and why you can use the output port and don't need to use the state port - is because you are using a delay block. This breaks the algebraic loop already.
The reason why the state port is used instead of the output port for algebraic loops is that these two outputs are set in a different time in the control.