Split vector in MATLAB

I’m trying to elegantly split a vector. For example,

vec = [1 2 3 4 5 6 7 8 9 10]
According to another vector of 0’s and 1’s of the same length where the 1’s indicate where the vector should be …