?? ceshi2.m
字號:
close all
clear all
clc
% set parameter
M=80;
M2=M/10;
M3=M-M2;
T=6;
Pc=0.6;
Pm=0.004;
N=7;
Len=10;
Lenth=N*Len;
Phi=zeros(M,Lenth);
BestValue=zeros(1,T);
% Generater the first generation of the population
Chro=round(rand(M,Lenth));
Phi=DecodeChro(Chro,M,Lenth,N,Len);
Phi=pi*Phi/2046;
figure(1)
mesh(Phi);
MaxFitness=zeros(1,T);
AveFitness=zeros(1,T);
% Calculate Object fitness
Phi=DecodeChro(Chro,M,Lenth,N,Len);
Phi=pi*Phi/2046;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555
dr=0.8;
k=2*pi*dr;
Value=ones(M,201);
MaxValue=zeros(M,1);
Index=zeros(M,1);
% find the max value and it's index
s=0;
for j=1:M
s=0;
for f=-1:0.01:1
s=s+1;
for n=1:N
Value(j,s)=Value(j,s)+exp(i*(k*f*n+Phi(j,n)));
end
Value(j,s)=abs(Value(j,s));
if Value(j,s)>MaxValue(j,1)
MaxValue(j,1)=Value(j,s);
Index(j,1)=f;
end
end
end
Lmin=MaxValue;
LIndex=zeros(M,1);
Value1=ones(M,201);
% find the first minimal value on the left
for j=1:M
s=0;
for f=Index(j,1):-0.01:-1
s=s+1;
for n=1:N
Value1(j,s)=Value1(j,s)+exp(i*(k*f*n+Phi(j,n)));
end
Value1(j,s)=abs(Value1(j,s));
if Value1(j,s)<=Lmin(j,1)
Lmin(j,1)=Value1(j,s);
else
break;
end
LIndex(j,1)=f;
end
end
% find the first minimal value on the right
Rmin=MaxValue;
RIndex=zeros(M,1);
Value2=ones(M,201);
for j=1:M
s=0;
for f=Index(j,1):0.01:1
s=s+1;
for n=1:N
Value2(j,s)=Value2(j,s)+exp(i*(k*f*n+Phi(j,n)));
end
Value2(j,s)=abs(Value2(j,s));
if Value2(j,s)<=Rmin(j,1)
Rmin(j,1)=Value2(j,s);
else
break;
end
RIndex(j,1)=f;
end
end
Value3=ones(M,201);
Lmax=zeros(M,1);
for j=1:M
s=0;
for f=-1:0.01:LIndex(j,1)
s=s+1;
for n=1:N
Value3(j,s)=Value3(j,s)+exp(i*(k*f*n+Phi(j,n)));
end
Value3(j,s)=abs(Value3(j,s));
if Lmax(j,1)<Value3(j,s)
Lmax(j,1)=Value3(j,s);
end
end
end
Value4=ones(M,201);
Rmax=zeros(M,1);
for j=1:M
s=0;
for f=RIndex(j,1):0.01:1
s=s+1;
for n=1:N
Value4(j,s)=Value4(j,s)+exp(i*(k*f*n+Phi(j,n)));
end
Value4(j,s)=abs(Value4(j,s));
if Rmax(j,1)<Value4(j,s)
Rmax(j,1)=Value4(j,s);
end
end
end
% the Fitness value
LV=Lmax./MaxValue;
RV=Rmax./MaxValue;
dBLV=20*log10(LV);
dBRV=20*log10(RV);
Fitness=max(0,(dBLV+17))+max(0,(dBRV+11));
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -