pick only the first element of elements within range
Show older comments
I would really appreciate some help on this. I have data like these (in the form of column vectors):
152.500000000000
166.500000000000
169
172.500000000000
174
179
184.500000000000
188
189.500000000000
191.500000000000
193
199.500000000000
203
and I want to start from the first one, find if there are following values that are within a range of 10, if there are keep the value of the checked element and delete the rest (within the range) and continue working downwards like that; if there are not following values within the range of 10 keep the value of the checked element. For instance in this dataset as an output I want to have 152.5 (no other values within range 10), 166.5 (delete 169, 172.5, 174), 179 (delete 184.5, 188), 189.5 (delete 191.5, 193, 199.5), 203. Thank you in advance
Accepted Answer
More Answers (1)
the cyclist
on 29 May 2017
Here is one way:
in = [152.5;
166.5;
169;
172.5;
174;
179;
184.5;
188;
189.5;
191.5;
193;
199.5;
203];
n = 1;
out = in;
while n < numel(out)
if out(n+1) <= out(n) + 10
out(n+1) = [];
else
n = n+1;
end
end
1 Comment
MARIANNA.KI
on 29 May 2017
Categories
Find more on Propagation and Channel Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!