Hi,
I understand that you are facing the error in ga function when you are trying to run code from https://ch.mathworks.com/help/bioinfo/ug/genetic-algorithm-search-for-features-in-mass-spectrometry-data.html.
When I tried to reproduce the error on my end, I didn't face any errors.
One possible reason for the error could be because of some issue in preprocessing step. Make sure that the data is preprocessed as mentioned and that the variables MZ, Y and grp are of same dimensions as shown in the article.
Hope it helps.
Regards,
Khalid