?? blind_cma.m.txt
字號:
% Blind channel estimation/equalization
% adpative CMA method in Fractional space
%% Copyright: Xiaohua(Edward) Li, Assistant Professor% Department of Electrical and Computer Engineering% State University of New York at Binghamton% http://ucesp.ws.binghamton.edu/~xli% June 2003%T=1000; % total number of data
dB_max=30;
dB_inter=3;
%%%%%%%%% Simulate the Received noisy Signal %%%%%%%%%%%
N=5; % smoothing length N+1
Lh=5; % channel length = Lh+1
Ap=4; % number of subchannels or receive antennas
h=randn(Ap,Lh+1)+sqrt(-1)*randn(Ap,Lh+1); % channel (complex)
for i=1:Ap, h(i,:)=h(i,:)/norm(h(i,:)); % normalize
end
s=round(rand(1,T))*2-1; % QPSK or 4 QAM symbol sequence
s=s+sqrt(-1)*(round(rand(1,T))*2-1);
SER=zeros(1,dB_max);%set the initi of ser
for dB=0:dB_inter:dB_max
%dB=20;
% generate received noisy signal
x=zeros(Ap,T); % matrix to store samples from Ap antennas
SNR=zeros(1,Ap);
for i=1:Ap
x(i,:)=filter(h(i,:),1,s);
vn=randn(1,T)+sqrt(-1)*randn(1,T); % AWGN noise (complex)
vn=vn/norm(vn)*10^(-dB/20)*norm(x(i,:)); % adjust noise power
SNR(i)=20*log10(norm(x(i,:))/norm(vn)); % Check SNR of the received samples
x(i,:)=x(i,:)+vn; % received signal
end
%SNR=SNR % display and check SNR
%%%%%%%%%%%%% adaptive equalizer estimation via CMA
Lp=T-N; %% remove several first samples to avoid 0 or negative subscript
X=zeros((N+1)*Ap,Lp); % sample vectors (each column is a sample vector)
for i=1:Lp
for j=1:Ap
X((j-1)*(N+1)+1:j*(N+1),i)=x(j, i+N:-1:i).';
end
end
e=zeros(1,Lp); % used to save instant error
f=zeros((N+1)*Ap,1); f(N*Ap/2+3)=1; % initial condition
R2=2; % constant modulas of QPSK symbols
mu=0.001; % parameter to adjust convergence and steady error
for i=1:Lp
e(i)=abs(f'*X(:,i))^2-R2; % instant error
f=f-mu*2*e(i)*X(:,i)*X(:,i)'*f; % update equalizer
%f(N*Ap/2)=1;
% i_e=[i/10000 abs(e(i))] % output information
end
sb=f'*X; % estimate symbols (perform equalization)
% calculate SER
H=zeros((N+1)*Ap,N+Lh+1); temp=0;
for j=1:Ap
for i=1:N+1
temp=temp+1;
H(temp,i:i+Lh)=h(j,:);
end % channel matrix
end
fh=f'*H; % composite channel+equalizer response should be delta-like
temp=0;
temp=find(abs(fh)==max(abs(fh))); % find the max of the composite response
sb1=zeros(1,size(sb));
sb1=sb./(fh(temp)); % scale the output
sb1=sign(real(sb1))+sqrt(-1)*sign(imag(sb1)); % perform symbol detection
start=N+1-temp; % general expression for the beginning matching point
sb2=sb1(10:length(sb1))-s(start+10:start+length(sb1)); % find error symbols
SER(dB+1)=length(find(sb2~=0))/length(sb2) ; % calculate SER
%figure(3);
%plot(dB,SER(dB));
end
if 1
figure(1);
subplot(221),
plot(s,'o'); % show the pattern of transmitted symbols
grid,title('Transmitted symbols'); xlabel('Real'),ylabel('Image')
axis([-2 2 -2 2])
subplot(222),
plot(x,'o'); % show the pattern of received samples
grid, title('Received samples'); xlabel('Real'), ylabel('Image')
subplot(223),
plot(sb,'o'); % show the pattern of the equalized symbols
grid, title('Equalized symbols'), xlabel('Real'), ylabel('Image')
%subplot(224),
%ii=1:(N+1)*Ap;
%stem(ii,f(ii));
%grid,title('equalization coefficience ');% xlabel('Real'),ylabel('Image')
figure(2);
%subplot(224),
plot(abs(e)); % show the convergence
grid, title('Convergence'), xlabel('n'), ylabel('Error e(n)')
end
figure(3);
i=0:dB_inter:dB_max;
semilogy(i,SER(i+1),'gp-');
grid;
legend('SGDCMA');
ylabel('誤碼率');xlabel('信噪比dB');
figure(4);
subplot(221),
h=reshape(h,1,(Ap*(Lh+1)));
ii=1:(N+1)*Ap;
stem(ii,h(ii));
grid,title('channel impluse response');% xlabel('Real'),ylabel('Image')
subplot(222),
ii=1:(N+1)*Ap;
stem(ii,f(ii));
grid,title('equalization coefficience ');% xlabel('Real'),ylabel('Image')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -