www.pudn.com > GA-array.zip > griewangk.m, change:2015-06-07,size:841b


function [eval]=griewangk(sol) 
 
[px,py] = size(sol); 
am0=sol(:,1:4); 
am=[am0 fliplr(am0)]; 
beta0=sol(:,5:8); 
beta=[beta0 fliplr(beta0)]; 
for i=1:px 
    imag=sqrt(-1); 
    element_num=8;%阵元数为8 
    d_lamda=1/2;%阵元间距d与波长lamda的关系 
    theta=linspace(-180,180,200); 
    % theta0=0;%来波方向 
    w=exp(imag*beta(i,:)'); 
    for  j=1:length(theta) 
        a=am(i,:)'.*exp(imag*2*pi*d_lamda*sin(theta(j)*pi/180)*[0:element_num-1]'); 
        p(j)=w'*a/sum(am(i,:)); 
    end 
 
    pp=[abs(p)]; 
    sllx(i)=0; 
    [maxpp,maxindex]=max(pp); 
    for ii=maxindex+1:length(theta)-1 
        if pp(ii-1)<pp(ii)&&pp(ii+1)<pp(ii) 
            sllx(i)=pp(ii); 
            break; 
        end 
         sllx(i)=maxpp; 
    end 
    eval(i)=sllx(i)/maxpp; 
    if eval(i)==0 
        eval(i)=1; 
    end 
end 
eval=eval';