Mohammed, make sure that the PopInitRange, LB and UB variables that you set are the correct size. PopInitRange (which is set using psooptimset) should be a 2 x nvars matrix (that's two rows, and nvars columns). LB and UB should both be 1 x nvars, i.e. row vectors.
Hi Sam, this the error msg: I have tried several times to modify the dimensions but it doesnt work
Index exceeds matrix dimensions.
Error in psocheckpopulationinitrange (line 9)
index(~lowerInf) = LB(~lowerInf) ~= lowerRange(~lowerInf) ;
Error in pso (line 214)
options.PopInitRange = ...