📄 ui_adapt.m.bak
字号:
function [] = ui_adapt();
dfec_global;
ui_private_global;
newparams;
% print text message and lock menu
set(h_msg,'BackgroundColor', [0 1 0]);
set(h_msg,'FontAngle','italic', 'String','adapting DFE...'); drawnow;
set(fig_menu,'HandleVisibility','off'); drawnow;
% Create symbol stream
a=make_src(constellation,Lsim);
sig=10^(-max(SNR)/10);
gamma=mean(abs(a).^4);
% Transmit through noisy channel
if (spacing==1),
n=make_noise(sig,real_noise,Lsim);
r=filter(c,1,a)+n;
elseif (spacing==1/2)
na=make_noise(sig,real_noise,Lsim);
nb=make_noise(sig,real_noise,Lsim);
ra=filter(ca,1,a)+na;
rb=filter(cb,1,a)+nb;
end;
% Initialize filters
if (spacing==1)
fn=f0;
dn=d0;
else
fb0=f0(1:2:Nf);
fa0=f0(2:2:Nf);
fan=fa0;
fbn=fb0;
dn=d0;
Nfa=length(fan);
Nfb=length(fbn);
end;
% Initialize variables
z=zeros(1,Lsim);
ahat=zeros(1,Lsim);
ef=zeros(1,Lsim);
ed=zeros(1,Lsim);
% Decide structure of adaptation
switch algorithm,
% LMS
case 1,
structure=2; % DFE structure
alg=1; % LMS algorithm
% DD
case 2,
structure=2; % DFE structure
alg=2; % DD algorithm
% CMA
case 3,
structure=2; % DFE structure
alg=3; % CMA algorithm
% IIR-LMS
case 4,
structure=1; % LE structure
alg=1; % LMS algorithm
% IIR-DD
case 5,
structure=1; % LE structure
alg=2; % DD algorithm
% IIR-CMA
case 6,
structure=1; % LE structure
alg=3; % CMA algorithm
% Labat
case 7,
structure=3; % Labat LE structure
alg=4; % Labat algorithm
end;
% Adapt in chunks of size D
D=500;
if (spacing==1)
fhist=zeros(Nf,round(Lsim/D));
dhist=zeros(Nd,round(Lsim/D));
fahist=[];
fbhist=[];
else
fhist=[];
fahist=zeros(length(fa0),round(Lsim/D));
fbhist=zeros(length(fb0),round(Lsim/D));
dhist=zeros(Nd,round(Lsim/D));
end;
l=2;
% Adapt!
% BSE
start=max(Nf+Nd,D+1);
if (spacing==1)
for n=start:D:Lsim-D+1,
% Initialize regressors
m=n-1;
if ((structure==1) & (n~=start))
Rn=r(m:-1:m-Nf);
Zn=z(m-1:-1:m-Nd);
elseif ((structure==2) & (n~=start))
Rn=r(m:-1:m-Nf);
Zn=ahat(m-1:-1:m-Nd);
else
Rn=zeros(Nf,1);
Zn=zeros(Nd,1);
end;
zn=z(m);
% Adapt on a block of data
aad=a((n:n+D-1)-delta+1);
rr=r(n:n+D-1);
[fL,dL,zz,eef,eed,aahat]=adapt(spacing,aad,rr,...
fn,Rn,dn,Zn,muf,mud,...
structure,constellation,alg,zn);
% Update variables
nn=n:n+D-1;
z(nn)=zz;
ahat(nn)=aahat;
ef(nn)=eef;
ed(nn)=eed;
fn=fL;
dn=dL;
% Store trajectories
fhist(:,l)=fL;
if (size(dL)>0)
dhist(:,l)=dL;
end
l=l+1;
% Display progress
cv=10*log10(mean(abs(aahat-zz).^2));
cv=round(10*cv)/10;
pdone=round(10*100*n/Lsim)/10;
pdone=[num2str(pdone) '% done, cv=' num2str(cv) ' dB'];
set(fig_menu,'HandleVisibility','on'); drawnow;
set(h_msg,'BackgroundColor', [0 1 0]);
set(h_msg,'FontAngle','normal', 'String',pdone); drawnow;
end;
if (my_isreal(fL)) fL=real(fL); end;
if (my_isreal(dL)) dL=real(dL); end;
% FSE
else
for n=max(Nf+Nd,D+1):D:Lsim-D+1,
% Initialize regressors
m=n-1;
if ((structure==1) & (n~=start))
Ran=ra(m:-1:m-Nfa+1);
Rbn=rb(m:-1:m-Nfb+1);
Zn=z(m-1:-1:m-Nd);
elseif ((structure==2) & (n~=start))
Ran=ra(m:-1:m-Nfa+1);
Rbn=rb(m:-1:m-Nfb+1);
Zn=ahat(m-1:-1:m-Nd);
else
Ran=zeros(Nfa,1);
Rbn=zeros(Nfb,1);
Zn=zeros(Nd,1);
end;
zn=z(m);
% Adapt on a block of data
aad=a((n:n+D-1)-delta+1);
rra=ra(n:n+D-1);
rrb=rb(n:n+D-1);
[faL,fbL,dL,zz,eef,eed,aahat]=adapt(spacing,aad,rra,rrb,...
fan,Ran,fbn,Rbn,dn,Zn,muf,mud,...
structure,constellation,alg,zn);
% Update variables
nn=n:n+D-1;
z(nn)=zz;
ahat(nn)=aahat;
ef(nn)=eef;
ed(nn)=eed;
fan=faL;
fbn=fbL;
dn=dL;
% Store trajectories
fahist(:,l)=fan;
fbhist(:,l)=fbn;
if (size(dL)>0)
dhist(:,l)=dL;
end;
l=l+1;
% Display progress
cv=10*log10(mean(abs(aahat-zz).^2));
cv=round(10*cv)/10;
pdone=round(10*100*n/Lsim)/10;
pdone=[num2str(pdone) '% done, cv=' num2str(cv) ' dB'];
set(fig_menu,'HandleVisibility','on'); drawnow;
set(h_msg,'BackgroundColor', [0 1 0]);
set(h_msg,'FontAngle','normal', 'String',pdone); drawnow;
end;
if (my_isreal(faL)) faL=real(faL); end;
if (my_isreal(fbL)) fbL=real(fbL); end;
if (my_isreal(dL)) dL=real(dL); end;
fL=zeros(Nf,1);
fL(1:2:Nf)=fbL;
fL(2:2:Nf)=faL;
end;
FL=freqz(fL,1,256,'whole');
FaL=freqz(faL,1,256,'whole');
FbL=freqz(fbL,1,256,'whole');
% Store cluster plot
acluster=z;
% Store final channel-forward equalizer combo
if (spacing==1)
hL=conv(c,fL);
else
C=convmtx(c,Nf);
C=C(2:2:size(C,1),:);
hL=C*fL;
end;
NhL=length(hL);
HL=freqz(hL,1,256,'whole');
% If LMS, effective filter
% with feedback is known
DELTA=delta+pdelay-1;
if (algorithm==1)
deltaL=delta;
ddL=zeros(max(NhL,DELTA+Nd),1);
if (Nd>0)
ddL(DELTA+(1:Nd))=dL;
end;
if (DELTA+Nd>NhL)
hL=[hL; zeros(DELTA+Nd-NhL,1)];
end;
HL=freqz(hL,1,256,'whole');
% Otherwise, stipulate cursor is
% maximum channel-forward equalizer tap and estimate
% an effective channel
else
[val,deltaL]=min(abs(hL-1));
DELTA=deltaL+pdelay-1;
ddL=zeros(max(NhL,DELTA+Nd),1);
if (Nd>0)
ddL(DELTA+(1:Nd))=dL;
end;
if (DELTA+Nd>NhL)
hL=[hL; zeros(DELTA+Nd-NhL,1)];
end;
HL=freqz(hL,1,256,'whole');
end;
DL=freqz(dL,1,256,'whole');
DDL=freqz(ddL,1,256,'whole');
% Update adaptation figures
ui_fimp;
ui_ffreq;
ui_traj;
ui_aerr;
ui_acluster;
ui_fcluster;
% clear text message, unlock menu, enable facets, dim spike
set(fig_menu,'HandleVisibility','on'); drawnow;
set(h_msg,'BackgroundColor', [0.8 0.8 0.8]);
set(h_msg,'FontAngle','normal', 'String',''); drawnow;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -