multiple convex hull clusters to plot in a single figure

My data has 3 columns.. x (x axis data), y (y axis data) and z (cluster number). Each cluster has more than 3 points and they are all in order.
Here is how the data looks:
I want to be able to apply a convex hull for each set of clusters and then plot the entire result together. My code is unable to do that instead it is throwing up a figure (see below)
[ndata, text, alldata] = xlsread(fullfile(source_dir));
[~, y] = sort(ndata(:,end));
As = ndata(y,:);
lon = As(:,1);
lat = As(:,2);
cluster = As(:,3);
%%To find number of points in a cluster (repetitions)
rep = zeros(size(cluster));
for j = 1:length(cluster)
rep(j) = sum(cluster==cluster(j));
end
%%Less than 3 points in a cluster are filtered out
x = lon (rep>3);
y = lat (rep>3);
z = cluster (rep>3);
%%convex hull for each cluster plotted ....hold....then display all.
figure
hold on
clusters = unique(z);
for i = 1:size(z)
k=convhull(x( z == clusters(i)), y( z == clusters(i)));
plot(x, y, 'b.'); %# plot cluster points
plot(x(k),y(k),'r-'); %# plots only k indices, giving the convex hull
end
Please could someone help me! Thank you very much, I really appreciate your help...........

답변 (1개)

Matt J
Matt J 2014년 3월 4일

0 개 추천

I don't fully understand what you're trying to do, but it sounds like the PATCH command would be better suited than PLOT.

카테고리

도움말 센터File Exchange에서 Computational Geometry에 대해 자세히 알아보기

질문:

2014년 3월 4일

답변:

2014년 3월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by