mtex icon indicating copy to clipboard operation
mtex copied to clipboard

Allow cmeans for vector3d (super low priority)

Open kilir opened this issue 5 years ago • 1 comments

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

kilir avatar Aug 21 '18 12:08 kilir

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

kilir avatar Oct 23 '18 19:10 kilir