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 x_1 does not fall below 0.
unfeas(x{1}<0) = true;
Enforce that the value of u_1 is not 1 if x_1 is below 0.5.
unfeas(x{1}<0 & u{1}==1) = true;