clustering for a Matrix
Show older comments
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
More Answers (1)
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
Youcef Benotmane
on 8 Apr 2015
Categories
Find more on Axis Labels 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!