CVX variables can’t be used in an array index.After CVX completes 9f successfully), all CVX variables are populated by their optimal numerical values and may be used the same as any other MATLAB variables.
If you show more clearly what you are trying to accomplish, perhaps a more specific assessment can be made as to whether and how it can be done. It may be that use of binary or integer variable declarations in CVX allow you to indirectly accomplish what you want with indexing, but not necessarily in a convenient manner.
Thank you for the quick response. I am trying to solve an optimal control problem in which the constraints are a function of the state variables, for which I need to define an index ‘j’. Index ‘j’ represents x(1) in the upper bound constraint x_max(j,i). ‘i’ is the time index.
See below code and picture:
The upper bound x_max on variable x(2) is function of x(1).
I think you are going to have to introduce binary or integer variables, used in something along the lines of Big M, in order to specify which constraint (upper bound) should be chosen for enforcement (an If Else.kind of thing). It may be messy and I don’t have the energy to work out the details, so best of luck if you try to do this.