资源简介

直线阵 遗传算法 优化幅相 降低副瓣 matlab

资源截图

代码片段和文件信息


close all
clear all
clc
%------------------遗传算法用于赋形---------十进制编码---------------
%---------------------------电流幅度、相位加权-----------------------
c=3e8;                     % 光速
fc=6e9;                    % 工作频率(hz)
numda=c/fc;                % 波长 wave length

N=40;                      % 阵列数
d=0.5*numda;               % 阵元间距
L=N*d;                     % 天线长
k=(2*pi)/numda;            % 波数
fs=10;                      % 采样频率
theta=-90:1/fs:90;    % 方位角度范围(采样范围)(rad)
Ns=length(theta);          % 采样点数
theta_d=0;                % 主波束方向
% theta_d=0时w1=w2=...=wM=1此时即为静态方向图
u=sind(theta)-sind(theta_d);
v=k*d*u;

%----------------------------------------------------------------
fitness_function=4;  % 适应度函数选择
selection_method=2;  % 选择方法[12345]
crosser_method=3;   % 交叉方法[12345]
mutation_method=3;   % 变异方法[123]

NN1=10;
NN2=10;
%---------------------参数设置------------------------
SLVL=-30;      % 副瓣电平
R=10.^(-SLVL/20);
ripple0=1;     % 主瓣纹波
gen_max=100;
popsize=40;
coef=5;

Const=60;
alpha0=0.9*ones(1coef*popsize);
beta0=zeros(1coef*popsize);
beta0=1-alpha0;

%------------------------期望波束----------------------------------
N0=(Ns-1)/2;
thetal=-20;
thetar=20;
Nl=thetal*fs;
Nr=thetar*fs;
Nsl=N0+Nl;
Nsr=N0+Nr;
for n=1:Ns                  %期望得到-20~20°的平顶波束
    if theta(n)<=20 && theta(n)>=-20
        Ed(n)=1;
    else
        Ed(n)=0;
    end
end
Sd=abs(Ed)/max(abs(Ed));
Gd=20*log10(Sd);

for ttt=1:1
    
    %=====================初始群体的产生=====================================
    %--------随机产生初始群体-------
    In_init=rand(coef*popsizeN/2);
    Vn_init=2*pi*rand(coef*popsizeN/2);
    %----------初始方向图--------------
    E_init=zeros(coef*popsizeNs);
    for p=1:coef*popsize
        for n=1:N/2
            E_init(p:)=E_init(p:)+In_init(pn)*exp(j*Vn_init(pn))*cos((n-0.5)*v);
        end
        S_init(p:)=abs(E_init(p:))/max(abs(E_init(p:)));
        G_init(p:)=20*log10(S_init(p:));
        
        S_main_max(p)=max(abs(S_init(p[(Nsl+NN1): (Nsr-NN1)])));
        S_main_min(p)=min(abs(S_init(p[(Nsl+NN1): (Nsr-NN1)])));
        S_side_max(p)=max(abs(S_init(p[1:(Nsl-NN2)(Nsr+NN2):Ns ])));
        
        %MSLL_init(p)=min(abs(G_init(p[1:(Nsl-NN2)(Nsr+NN2):Ns ])));%越大越好
        MSLL_init(p)=-20*log10(S_side_max(p)/S_main_max(p));               %越大越好
        ripple_init(p)=Const-20*log10(S_main_max(p)/S_main_min(p));  %越小越好
        
        if fitness_function==1    % 偏副瓣
                if MSLL_init(p)<=0 || ripple_init(p)<=0
                    alpha0(p)=0;beta0(p)=0;
                elseif  ripple_init(p)<=30
                    alpha0(p)=0.1;beta0(p)=0.01;
                elseif  ripple_init(p)<=40
                    alpha0(p)=0.1;beta0(p)=0.03;
                elseif  ripple_init(p)<=50
                    alpha0(p)=0.1;beta0(p)=0.05;
                elseif  ripple_init(p)<=55
                    alpha0(p)=0.1;beta0(p)=0.06;
                elseif

评论

共有 条评论