Hello. i have a Matrix that gave me the value of the position of two diffent point in the axes X and Y as it shown in my message here in my message.
632.9835 434.9715
618.8766 304.8749
607.9271 205.5682
598.9417 228.5058
611.2706 185.7411
616.5711 173.5655
103.1873 471.9625
614.9672 177.8059
107.3455 471.0524
604.2020 192.8504
111.7277 469.6861
593.4920 211.2193
107.6531 461.7784
592.1981 213.4811
106.9523 453.9532
as you can see there are values in the first column which they are close to 600 and other value which they are close to 100. i want to create two other matrix ! one take all the lines where the value are close to 600 and other take value close to 100. i have heard that clustering can do such operation but i never used it before ! i hope i can get help here :)
sorry for my bad english :p

 Accepted Answer

You could use clusterdata but with such a dichotomous data set and only a single variable, it would be overkill. How about
mn=mean(data(:,1)); % the average of the first column
idx=data(:,1)>mn; % those that are larger; the rest will obviously be smaller
x=data(idx,:); % the higher values
y=data(~idx,:); % and the lower

2 Comments

i copied your code in my Matlab but it gave a bit Matrix with a lot of numbers wich i don't have any idea of what they means !
dpb
dpb on 8 Apr 2015
Edited: dpb on 9 Apr 2015
ix will be a logical vector of length(data) with values of "true" (1) for the locations of entries in the first column of your data array which are larger than the mean, "false" (0) elsewhere.
Hence, x and y are the two separated-by-size arrays of the original array you asked for in your original posting.
If, instead, you're actually interested in the locations then
ixBig=find(idx); % will give you the locations of those in the large group
ixLit=find(~idx); % is the small values locations (rows)
Or, if the question is which group each belongs to...
>> grp=[ix+1].'
grp =
2 2 2 2 2 2 1 2 1 2 1 2 1 2 1
>>
converts the logical array to a group number array for each row of data where "1" --> "BIG"; "2" --> "LITTLE".

Sign in to comment.

More Answers (1)

Thorsten
Thorsten on 7 Apr 2015
Edited: Thorsten on 7 Apr 2015
For this example clustering would be probably overkill. It's sufficient to determine the distance to the values in the first column to either 100 or 600 and then group it according to the minimum distance.
If your data matrix above is store in X, use
x = X(:,1);
[~, ind] = min(abs([x - 100 x - 600]), [], 2);
Plot the results to check:
y = X(:, 2);
plot(x(ind==1), y(ind==1), 'r.')
hold on
plot(x(ind==2), y(ind==2), 'b.')

1 Comment

i understand your code a bit but i think this is not really what i am looking for because it is not always where i get values close to 100 and 600! to be more precis my matrix give me the position of two moving object in same time and i want to separate between the two objects by making comparison between the values of the matrix.

Sign in to comment.

Tags

No tags entered yet.

Asked:

on 7 Apr 2015

Edited:

dpb
on 9 Apr 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!