Please note that macOS Yosemite is not a supported operating system for the R2019a release. Based on the error message, it looks like the issue is caused by incompatible libraries. To resolve this, please upgrade to one of the supported operating systems listed in the link below.
If you cannot upgrade the OS, you can also try using the "kmeans" function from the Statistics and Machine Learning Toolbox. For example:
I = imread('cameraman.tif');
I = im2double(I);
idx = kmeans(I(:), 3);
L = reshape(idx, size(I));
B = labeloverlay(I,L);
imshow(B);
Please find the documentation for "kmeans" linked below.
Best Answer