Reputation: 2178
I have two arrays. One for data and one which contains 1
for each item which I want to select from an array and 0
for each item which I want to ignore.
data = [1 2 3 4 5];
list = [1 0 1 0 1];
Is there a quick one-liner way to get checked elements (1, 3 and 5) from the data array without doing something like:
newdata = [];
for i=1:numel(data)
if list(i) == 1
newdata(end+1) = data(i);
end
end
Upvotes: 0
Views: 74