⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vblast.m

📁 mimo通信系统matlab仿真。 qpsk调制
💻 M
字号:
close all;
clear all;
Tx_n = 4;             %发射天线4
Rx_n = 4;             %接收天线4
index = 2;            %for modu index:1/2/4/6 bits per symbol
frame_length = 48;    %帧长度48
numloop=100;          %符号数/载波100
                      % SNR_dB=5;
SNR_dB_MIN=0;
SNR_dB_MAX=50;
SNR_dB_stmp=5;
bertmp=zeros(1,numloop);
BER=zeros(1,length(SNR_dB_MIN:SNR_dB_stmp:SNR_dB_MAX));
if Rx_n < Tx_n
	disp_str = ['error!!!the Rx_n must no less than Tx_n'];
	disp(disp_str);
	return;
end
for SNR_dB=SNR_dB_MIN:SNR_dB_stmp:SNR_dB_MAX
   for looptmp=1:numloop
source = rand(1,Tx_n*frame_length*index)>0.5;    %生成信号
column_num = length(source) / Tx_n;
% encode; the dim of encoder_output is Tx_n*(frame_length*index)
encoder_output = zeros(Tx_n, column_num);
%——————————————————————————————————%
%                             译码                                   %
%——————————————————————————————————%
for col = 1:column_num           %列
	for row = 1:Tx_n             %行
		encoder_output(row, col) = source((col-1)*Tx_n + row);
	end
end
% modulation ; the dim of modu_output is Tx_n  fream_length
modu_output=zeros(Tx_n,frame_length);
%——————————————————————————————————%
%                              调制                                  %
%——————————————————————————————————%
for t=1:Tx_n
    modu_output(t,:) = modulation(encoder_output(t,:), index);
end
%——————————————————————————————————%
%                           通过信道                                 %
%——————————————————————————————————%
  % the H of the channel with the dim is  Rx_n Tx_n
  H=zeros(Rx_n,Tx_n);
for rx = 1:Rx_n
	for tx = 1:Tx_n
		randn('state',sum(100*clock));        %每次重新设置到不同状态
		x = randn(1); 
		y = randn(1);
		alpha = sqrt(x^2+y^2);                %瑞利分布 模
		theta = 2*pi*rand(1);   
		H(rx,tx) = alpha*exp(j*theta);
	end
end
  %channel_output的维数是[Tx_n,frame_length]
channel_output = H*modu_output;
module_signal = [];
		for t=1:Tx_n
			module_signal =[ module_signal abs(channel_output(t,:))];			
		end
		signal_level = mean(abs(module_signal).^2);
		signal_level_dB = 10*log10(signal_level);
%——————————————————————————————————%
%                            加入高斯白噪声                          %
%——————————————————————————————————%
decoder_input = awgn(channel_output,SNR_dB,signal_level_dB);
%——————————————————————————————————%
%                              MMSE接收机                            %
%——————————————————————————————————%

%——————————————————————————————————%
%                                 解调                               %
%——————————————————————————————————%
for t = 1:Tx_n
demodu_output(t,:) = demodulation(decoder_input(t,:), index);
end
sink = zeros(1,Tx_n*frame_length*index);
%——————————————————————————————————%
%                             信号分离                               %
%——————————————————————————————————%
for i = 1:Tx_n
    sink(i:Tx_n:end)=demodu_output(i,:);
end
source=double(source);
[Num,Ber]=symerr(sink,source);
bertmp(looptmp)=Ber;
end
BER((SNR_dB-SNR_dB_MIN)/SNR_dB_stmp+1)=mean(bertmp);
end
figure;
semilogy(SNR_dB_MIN:SNR_dB_stmp:SNR_dB_MAX,BER,'*:');
grid on;
xlabel('SNR(db)');ylabel('BER');
title('V-BLAST of MMSE(no order)');
legend('Tx = 4','Rx = 4','QPSK modulation');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -