mtex
mtex copied to clipboard
Allow cmeans for vector3d (super low priority)
Kmeans works nicely with vector3d, however for cmeans doClustering
fails because sum
in vector3d/sum
doesn't handle the weights options. Maybe checking in cmeans/doClustering
for the type vector3d and using the weights to scale the vector might be an option?
vin=vector3d.rand(5);
vd=calcDensity(vin,'halfwidth',15*degree);
v=discreteSample(vd,1000);
km=kmeans(5);
[c,center] = km.doClustering(v);
% -- above works super nicely
cm=cmeans(5);
[c,center] = cm.doClustering(v);
Error using sum
Invalid option. Option must be 'double', 'native', 'default', 'omitnan' or
'includenan'.
Error in vector3d/sum (line 17)
s.x = sum(v.x,varargin{:});
Error in vector3d/mean (line 39)
m = sum(v,varargin{:});
Error in cmeans/doClustering (line 27)
cm.center(i) = mean(obj,'weights
Cheers, Rüdiger
So the issue is that @vector3d/mean does not handle weights, so would t be sufficeint to check if obj is of type vector3d and change to scaling the vectors by the weights? Rüdiger