User function (v1)

Syntax:
popu = userfun(popuin,figh,axsh);
 popu Structure (population) Resulted population
 popuin Structure (population) Input population
 figh Scalar Handle of figure
 axsh Matrix (nrow x nind) Handles of subplots (axes) on the figure

nrow: number of subplot-rows
nind: number of individuals, size of population

The Easy-IEC toolbox calls this function in every loop to evaluate the population. Because the evaluation depends on the user's problem, hence it is the user's duty to write this function. The main task of the function: to evaluate the actual population and to display plots and texts for the operator.

The user function must evaluate all individuals of the population. The popuin.chrom contains the chromosomes for every individuals (population variable).

The function must return the resulted population in popu variable.

The popuin is the actual population variable.

The figh is the handle of the interactive figure which includes the subplots. The user must draw plots and write texts on these subplots.

The axsh matrix contains the handles of the subplots.

Example:

function popu = userfun(popuin,figh,axsh);
%User function:

global param tout yout1 yout2 %global variables -> simulation
figure(figh);  %actual figure
nind = size(popu.chrom,1); %number of individuals (= columns)

popu = popuin;
%Loop:
for i = 1:nind,
  %Evaulation (-> tout, yout1, yout2)
  param = popu.chrom(i,:); %chromosome -> simulation
  sim('usersimu',[0 10]);

  %First subplot (1. output of simulation):
  subplot(axsh(1,i));
  plot(tout,yout1,'r-');
  %Second subplot (2. output of simulation):
  subplot(axsh(2,i));
  plot(tout,yout2,'r-');
  %Refresh the figure:
  drawnow
end