📄 lsls.m
字号:
clc
clear all
Nt = 2; % the number of transmitted antennas
Nr = 2; % the number of transmitted antennas
SNR = 2; % the system signal-to-noise ratio with dB
snr = 10.^(0.1*SNR); % the signal-to-noise with normal scale
snrp=snr;
T=2:1:30; % the number of symbol periods
Tp=T;
% Td=T-Tp;
hhh=zeros(1,length(T));
ggg=zeros(1,length(T));
hm=zeros(Nt*Nr,1); % channel mean
hh=eye(Nt*Nr); % channel covariance
% vv=eye(Tp*Nr); % noise covariance
% Hw=ones(Nr*Nt,1);
% Hw =sqrt(1/2)* (randn(Nr*Nt,1) + j* randn(Nr*Nt,1)); % channel
for ii = 1:length(T)
waitbar(ii/length(T));
Hw =sqrt(1/2)* (randn(Nr*Nt,1) + j* randn(Nr*Nt,1)); % channel
% nn=eye(Td(ii)*Nr); % noise covariance
% LS estimator
p=eye(Tp(ii)*Nr,Nt*Nr); % training symbol
pp=inv(p'*p)*p'; % wei ni
F=1/sqrt(snrp)*pp;
f0=zeros(Nt*Nr,1);
v=sqrt(1/2)*(randn(Nr*Tp(ii),1) + j*randn(Nr*Tp(ii),1)); % training noise
z=sqrt(snrp)*p*Hw+v; % receive
g=F*z+f0; % estimation
hhh(ii)=abs(Hw(1));
ggg(ii)=abs(g(1));
ww= waitbar(ii/length(T));
end
close(ww)
% figure
plot(T,hhh,'ko-')
hold on
plot(T,ggg,'k*-')
hold on
grid on
title('TX#-RX#')
% set(gca,'Xtick',[0,5,10,15,20,25,30],'Ttick',[-3,-2,-1,0,1,2,3,4,5])
axis([0 30 -3 5])
% xlabel('T')
% ylabel('hh')
% legend('h','g')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -