How to use if, else conditional loop on anonymous function handle?
Mostrar comentarios más antiguos
eva = evalclusters(meas, 'kmeans', 'CalinskiHarabasz', 'klist',[1:6])
Now, in the following example we use anonymous function handle:
load fisheriris
myfunc = @(X,K)(kmeans(X, K, 'emptyaction','singleton', 'replicate',5));
eva = evalclusters(meas, myfunc, 'CalinskiHarabasz', 'klist',[1:6])
kmeans returns indices, cluster center location, etc. I will like to put an if condition on myfunc before I pass it eva. So if other words, if the given condition fails, I will not like to run evalclusters.
4 comentarios
Adam
el 3 de Ag. de 2018
Can't you just write a regular function and create a handle to that? Then you can put if statements, for loops and whatever you want in it.
hello_world
el 3 de Ag. de 2018
Albert Fan
el 3 de Ag. de 2018
I don't quite understand you idea. The optimal number of clusters is determined by the evaluation object, and the function handle you fed in is just a clustering algorithm and that algorithm shouldn't be dependent on the optimal number of clusters. So what are you trying to achieve here?
hello_world
el 3 de Ag. de 2018
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Cluster Visualization and Evaluation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!