pick only the first element of elements within range
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
the cyclist
2017년 5월 29일
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
카테고리
도움말 센터 및 File Exchange에서 Propagation and Channel Models에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!