You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: IA.m
    path of file: ./repos/opt_matlab/第21章/例21.1
    
    the code of the file until where you have to start completion: function [best_x,fval]=IA(fun,popsize,iterm_max,pm,px,r,LB,UB)   %免疫算法,求极小
if isempty(pm)
    pm=0.1;
e
    
function [cbest,cworst,best]=f(pop,iterm,cbest,cworst)
popsize=size(pop,2);
best=pop(1);
worst=pop(1);
for i=2:popsize
    if pop(i).fitness<best.fitness
        best=pop(i);
    elseif pop(i).fitness>worst.fitness
        worst=pop(i);
    end