Can i know what is the solution for this error

Hello i found this error in matlab when i'm using kmeans function
Undefined function 'initkm' for input arguments of type 'single'.
Error in kmeans (line 65) center = initkm(cluster_n, data); % Initial cluster centers

5 Comments

Which release, which kmeans?
My version (R2012b) has no initkm in kmeans.m and line 65 is well within the header comment section, not even into executable code yet...
My version(R2012a) my OS is linux example: a=[1 3 4 5 6 3 2 9 6]; kmeans(a,3);
then i had the error
That runs just fine here...
Try
which kmeans
at command line -- sounds to me like you've got some other function in place of the one in the Statistics Toolbox. That much difference in m-file content doesn't sound right altho I guess there could have been extensive revisions between a and b releases. Unfortunately, I've no earlier version to compare to.
now i'm adding the function initkm i check it in the internet but i don't know the input
function [center, center_class] = initkm(cluster_n, data, data_class) % INITKM Find the initial centers for a K-means clustering algorithm.
% Roger Jang, 990831
% ====== Method 1: Randomly pick cluster_n data points as cluster centers class_n = max(data_class); center = []; center_class = []; for i = 1:class_n, this_data = data(find(data_class==i), :); this_data_n = size(this_data, 1); tmp = randperm(this_data_n); index = tmp(1:cluster_n); center = [center; this_data(index, :)]; center_class = [center_class; i*ones(cluster_n, 1)]; end
Clearly you're not using the Matlab Statistics Toolbox kmeans
Whatever/wherever you obtained it is where to find support for it; the Matlab forum can't help in all likelihood.

Answers (0)

This question is closed.

Tags

Asked:

on 8 Oct 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!