Specify contraints on the state and control variables
In order to specify constraints on the state and control variables, you can introduce unfeasibilty in your system function.
[x_next, stage_cost, unfeas] = sysfun(x, u, ~)
Unfeasibility, which must be the third output of your function, is a logical variable, and it can be any function of the state variables and control variables.
In your function, use logical indexing to set it to true for those conditions which must be unfeasible, according to your constraints.
Examples
Enforce that the value of
does not fall below 0. Enforce that the value of
is not 1 if
is below 0.5. unfeas(x{1}<0 & u{1}==1) = true;