Search code examples
matlabindices

Matlab: changing zero-one index vector to proper index vector


Suppose an index vector in binary like below

Input

1 1 0 0 1 0 1

1 2 3 4 5 6 7

Intended output

1 2 5 7

which denotes nth number to be chosen. So I want to change 1 1 0 0 1 0 1 to 1 2 5 7, is there some easy way for this?


Solution

  • The solution is using the function find(indicesBinary)