- I have a vector (parameter) : Z = [1 2 3 4 5 ............n].

- I have binary variables with length of Z : y(1),y(2).....y(n)

- such that, if y(i) is 1, then the ith element in Z_new should be zero.

- The rest elements should come from Z parameter

The Z parameter should restart in the non-zero position.

Another example :

if y(1) and y(2) are 1, then Z_new should be as follows:

Z_new = [0 0 1 2 3 4 ..... n].

Can you please help me formulating this problem?