Using clusterdata and extracting data from it's indexes.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Izuru
el 15 de Abr. de 2015
Comentada: Izuru
el 15 de Abr. de 2015
Hello,
I have an array of points say A = [1,13,14,2,15,16,3,17];
I use clusterdata (with criterion as distance) which returns me the cluster number each data point in A belongs to:
T = [1,2,2,1,2,2,1,2];
I want to have a new array which separates these data points into:
B = [1,2,3] C = [13,14,15,16,17]
How do I achieve this?
0 comentarios
Respuesta aceptada
Guillaume
el 15 de Abr. de 2015
Editada: Guillaume
el 15 de Abr. de 2015
Asplit = accumarray(T', A, [], @(v) {v});
Note that the output is a cell array where each cell is a cluster. It's much better to use a cell array than individually named variables.
The above line is equivalent to:
Asplit = cell(max(T), 1);
for cluster = 1:max(T)
Asplit{cluster} = A(T == cluster);
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!