In R, if we have a vector and a list of indices, we can express the idea that we want "all elements except these indices" using a negative index. In particular, consider the following R code:
data = rnorm(100)
indices = sample(1:length(data), length(data)/2)
training_data = data[indices]
test_data = data[-indices]
After this code, sampled_data contains all the elements in data whose indices are not included in indices. Is there an equivalent to this in matlab?
I tried directly using the same syntax (of course wtih () instead of [], but it just gave the error
Subscript indices must either be real positive integers or logicals.