Error when using kmedoids with custom distance function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Daniel
le 16 Oct 2014
Réponse apportée : Siddharth Sundar
le 17 Oct 2014
Hi,
I created a custom distance function which I used with linkage and it worked fine. Here is how I call it: Z = linkage(matrix_clean,'average','@new_dist');
When I try using kmedoids (from the stats toolbox) with a custom fucntion I get an error. Here is how I call the fucntion: [idx,C,sumd,d,midx] = kmedoids(matrix_clean,2,'Distance','@new_dist');
Here is the error:
Error using lower Not enough input arguments.
Error in kmedoids (line 242) distance = lower(methods{i});
How should I pass in my custom distance function in kmedoids?
Thanks,
Daniel
1 commentaire
Geoff Hayes
le 16 Oct 2014
Daniel - if this happens again, in the Command Window, type
which lower -all
Perhaps you have a custom function named lower that requires more than one input parameter and so is causing some confusion with the built-in MATLAB lower function.
Réponse acceptée
Siddharth Sundar
le 17 Oct 2014
Within the kmedoids function, there is a check on the distance metric to see if it is a string or a function handle. In your case, you have entered the function handle as a string and hence it is following a different code path from the one it should be following. All you would need to to is to use the command without quotes around your function handle:
[idx,C,sumd,d,midx] = kmedoids(matrix_clean,2,'Distance',@new_dist);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Text Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!