📄 lmscma.m
字号:
echo on
N=3000;
K=5;
M=4;
adaptsize=200;
actual_isi=[0.05 -0.063 0.088 -0.126 -0.25 0.9047 0.25 0 0.126 0.038 0.088];
adapt=[1 1 -1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 1 1 1 1 1 1 1 -1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 1 1 1 1 -1 -1 1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 1];
sigma=24;
delta=0.045;
Num_of_realizations=1;
mse_av=zeros(1,N-2*K);
x = randint(N,1,M);
info=qammod(x,M);
info=info.'
info(1:200)=adapt(1:200)+adapt(1:200)*j
echo off;
if (j==1);
echo on; end
y=filter(actual_isi,1,info);
y=awgn(y,sigma,'measured');
scatterplot(y)
realy=real(y);
imagy=imag(y);
scatterplot(y)
estimated_c=[0 0 0 0 0 1 0 0 0 0 0];
for k=1:N-2*K,
realy_k=realy(k:k+2*K);
realz_k(k)=estimated_c*realy_k.';
if(k<=200)
reale_k=adapt(k)-realz_k(k);
else
if (realz_k(k)>=0)
reale_k=1-realz_k(k);
else reale_k=-1-realz_k(k);
end
end
estimated_c=estimated_c+delta*reale_k*realy_k;
mse(k)=reale_k^2;
echo off
end;
mse=10*log(mse)
subplot(2,1,1)
plot(mse)
axis([0 N -50 0 ])
echo off;
estimated_ci=[0 0 0 0 0 1 0 0 0 0 0];
for k=1:N-2*K,
imagey_k=imagy(k:k+2*K);
imagez_k(k)=estimated_ci*imagey_k.';
if(k<=200)
imagee_k=adapt(k)-imagez_k(k);
else
if (imagez_k(k)>=0)
imagee_k=1-imagez_k(k);
else imagee_k=-1-imagez_k(k);
end
end
estimated_ci=estimated_ci+delta*imagee_k*imagey_k;
imagemse(k)=imagee_k^2;
echo off
end;
imagemse_av=10*log(imagemse);
subplot(2,1,2)
plot(imagemse_av)
axis([0 N -50 0])
result=realz_k+imagez_k*j;
scatterplot(result)
be=2^0.5
y=y./be
L_f=9; %抽头系数个数
mu=0.05; %步长
estimated_f1(1:L_f)=[0 0 0 0 0.1 0 0 0 0]; %chan1 均衡器抽头系数的初值
for k=L_f:N-L_f+1 %迭代次数
yout_1=y(k:-1:k-L_f+1);%卷积的时候,取值要特别注意,要搞清楚卷积的含义:r(n)=x(n)*h(n)=sum(m=1:L_f;h(m).x(n-m))
z_k1(k-L_f+1)=estimated_f1*yout_1.'; %chan1 均衡器的输出信号
e_k(k-L_f+1)=[1-(abs(z_k1(k-L_f+1)).^2)]*z_k1(k-L_f+1);
estimated_f1=estimated_f1+mu*e_k(k-L_f+1)*conj(yout_1); %权迭代 A2=1
end;
scatterplot(z_k1*be);
theinfo=info
ek=abs(theinfo(1:2000))-abs(z_k1(1:2000)*be);
ek=ek.^2
ek=10*log(ek)
figure;
plot(ek)
realy=round(realy*2^15/2)
imagy=round(imagy*2^15/2)
fid=fopen('input_real.h','w');
fprintf(fid,'int input_real[N]={');
fprintf(fid,'%d,',realy(1:N));
fprintf(fid,'}\n');
fclose(fid);
fid=fopen('input_imag.h','w');
fprintf(fid,'int input_imag[N]={');
fprintf(fid,'%d,',imagy(1:N));
fprintf(fid,'}\n');
fclose(fid);
fid=fopen('adapt.h','w');
fprintf(fid,'int adapt[200]={');
fprintf(fid,'%d,',adapt(1:200));
fprintf(fid,'}\n');
fclose(fid);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -