tags:

views:

41

answers:

1

I want to cluster an array, this array contain some angle I want to calculate the difference between of these degree and select one group between this array, this group should have maximum number and the difference between the member of that should not be larger than specific number.

for example if specific number is 30 and array is

[10 20 30 40 100 120 140]

answer should be

[10 20 30 40]

100-30 >= 30 so it is not included.

A: 
a = [10 20 30 40 100 120 140]; #initial array
b = []; #result array
s = 30;
for i = 1:length(a)
    if abs(a(i) - s) < s
        b = [b a(i)];
    end
end
tlayton
`b = a( abs(a-s) < s )`
Amro

related questions