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: FWA.m
    path of file: ./repos/opt_matlab/第25章/例25.14
    
    the code of the file until where you have to start completion: function [bestx,fval]=FWA(fun,Nf,Ng,iter_max,LB,UB)     %烟花算法
NC=size(LB,1);

    
function [bestx,fval]=FWA(fun,Nf,Ng,iter_max,LB,UB)     %烟花算法
NC=size(LB,1);
for i=1:Nf    %烟花数
    fireworks(i,:)=LB'+(UB-LB)'.*rand(1,NC);
    f1=fun(fireworks(i,:));
    if f1>=0     %求极小
        fitness(i,1)=1/(f1+1);
    else
        fitness(i,1)=abs(f1)+1;
    end