Dear forummers, I'm trying to solve a problem that is displayed in matlab below:- ??? Attempted to access x(2); index out of bounds because numel(x)=1. Error in ==> fit_fun at 5 Fit_fun_val= x(1)^2 + x(2)^2 + x(3)^2; Error in ==> jack_immune at 47 Sel_Ab_cri(ksel)=fit_fun(Ini_Ab(:,ksel)); I understand that (Ini_Ab(:,ksel)) has to have 3 numbers/datas, but the coding is looping. How am i able to modify the code as to have 3 numbers as well as a loop? Sorry for my poor explanation. Part of the code is as below:- for ksel=1:pop_size Sel_Ab_cri(ksel)=fit_fun(Ini_Ab(:,ksel)); end Thanks in advance. PS: Do let me know if i need to post the full code. Thanks.