(continued from comments under question).
Assuming you have a vector of data "x" and a vector of QC values "qc" and the qc values are logical where 'true' means "keep",
The benefit of the 2nd line above is that the size and index values of 'x' do not change.
If your qc values are numeric and range from j to i, you can set a threshold 't' where any qc values greater than t are accepted.
xAccepted = x(qc > t);
x(qc <= t) = NaN;