top_x = pop(b(1:options.topSize),:)
The code for Generating the initial population is This:
M = 50; % population size
n = 2;
pop = -50 + 100.*rand(M,n);
. This is done in a for loop. See Here for the entire code figure;
scatter(pop(:,1), pop(:,2), 'x'); and
figure;
scatter(top_x(:,1),top_x(:,2), 'x');
% Criteria for selecting top 'topSize' individuals based on fitness
% values(eval)
if strcmp(options.optmType, 'min')
[void, b] = sort(eval, 'descend'); % maximising
else
[void, b] = sort(eval, 'ascend'); % minimising
end
pop = pop(void);
top_x = pop(b(1:options.topSize),:); % select top individuals
optm_x = pop(b(1),:); % save optimal parameter
fv = eval(b(1)); % save optimal func. value
Subscript indices must either be real positive integers or logicals.
Error in ==> Imp
pop = pop(void);
void = round(void)
pop = pop(void)
??? Index exceeds matrix dimensions.
Error in ==> Imp at
pop = pop(void);
pop = mvnrnd(mu,Sigma,M)
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.