kmeans: intermittent dimension mismatch error

Bug Description

I encountered an intermittent issue when calling kmeans.

[idx, centroid] = kmeans(K, m);

where:

  • m = 6
  • K is attached as a CSV file (K.csv).

On the first execution, I get the following error:

Operator -: Wrong dimensions for operation [5x2] - [6x2], same dimensions expected.

However, if I execute the exact same command a second time, it works correctly without any modification.

Steps to reproduce

(How one can reproduce the issue - this is very important.) (Paste any relevant code and output)

K = csvRead("...\K.csv")
m = 6;
[idx, centroid] = kmeans(K, m);

K.csv

Edited by Adeline CARNIS