Here's an example with a 2x3x2 array, removing all the 9s and appending 0s:
data = reshape(1:12,[2 3 2])
siz = size(data);
idx = data == 9;
data(idx) = [];
data(end+1:end+nnz(idx)) = 0;
data = reshape(data,siz)
Notice the 10, 11, 12 are now in different locations. Is that what you want?