How to get the coordinate of a variable?

Is this related to your previous thread How to express constrain in CVX? ?

I don’t understand exactly what you want. If the desired index of B depends on the value of B (using a variable as an index), then it could be complicated to model, requiring introduction of additional binary variables. You need to be much clearer as to what you want to do.