瑞利信道仿真(瑞利信道下,2发2收,最大似然译码,空时编码,MATLAB仿真实现)

本文目录
瑞利信道下,2发2收,最大似然译码,空时编码,MATLAB仿真实现
function [FER,FER_uncoded,SER,SER_uncoded, BER, BER_uncoded]=stbc22(channel_model,K,Num,no_tx_antennas,no_rx_antennas,modulation)
%SNR upto 20 dBs
EbNo=[0:2:20];
%N, M: number of transmit and receive antennas
N=no_tx_antennas;
M=no_rx_antennas;
%initialize count
idx = 1;
h=waitbar(0,’Percentage Completed’);
set(h,’Position’,[230 60 275.25 56.25]);
set(h,’name’,’Please wait...’);
wb=9.09;
for SNR=EbNo
sigma=0.5/(10^(SNR/10));
% Num -》 number of packets
for packet_count=1:Num
% we are interested in transmitting ’K’ SYMBOLS not bits. Hence, K*2 for QPSK
% etc.
switch (modulation)
case ’BPSK ’
data=randint(K,N);
BIT=1;
case ’QPSK ’
data=randint(K*2,N);
BIT=2;
case ’8PSK ’
data=randint(K*3,N);
BIT=3;
case ’16QAM’
data=randint(K*4,N);
BIT=4;
otherwise
disp(’No Modulation’)
end
tx_bits=data.’;
temp=;
temp1=;
for i=1:N
[temp1 s P]=tx_modulate(tx_bits(i,:),modulation);
temp=[temp; temp1];
temp1=0;
end
%ready to transmit symbols of length ’K’
X=temp.’;
fr_length=length(X);
% block coding-Alamouti
x0=X(:,1);% required to verify a 1x1 system
x1=X;
x2(:,1)=-conj(X(:,2));
x2(:,2)=conj(X(:,1));
% form the channel matrix
for n=1:N
if channel_model==’AWGN ’
Hr(n,:,:)=ones(fr_length,N);
else
Hr(n,:,:)=(randn(fr_length,N)+j*randn(fr_length,N))/sqrt(2);
end
end
for n=1:M
%transmission matrix
H=reshape(Hr(n,:,:),fr_length,N);
Habs(:,n)=sum(abs(H).^2,2);
%received signal per receiver antenna
r1(:,n)=sum(H.*x1,2)/sqrt(N)+sqrt(sigma)*(randn(fr_length,1)+j*randn(fr_length,1));
r2(:,n)=sum(H.*x2,2)/sqrt(N)+sqrt(sigma)*(randn(fr_length,1)+j*randn(fr_length,1));
% demodulate the received signals
z1(:,n)=r1(:,n).*conj(H(:,1))+conj(r2(:,n)).*H(:,2);
z2(:,n)=r1(:,n).*conj(H(:,2))-conj(r2(:,n)).*H(:,1);
end
%uncoded(1,1)
r01=H(:,1).*x0+sqrt(sigma)*(randn(fr_length,1)+j*randn(fr_length,1));
%form estimates
for m=1:P
d01(:,m)=abs(r01-H(:,1)*s(m)).^2; % uncoded signal
%coded signals
d1(:,m)=abs(sum(z1,2)-s(m)).^2+(-1+sum(Habs,2))*abs(s(m))^2;
d2(:,m)=abs(sum(z2,2)-s(m)).^2+(-1+sum(Habs,2))*abs(s(m))^2;
end
% determine the minimum of estimates
%decision for detecting uncoded
[y0,i0]=min((d01),,2);
s0d=s(i0).’;
clear d01
%decision for detecting s1
[y1,i1]=min(d1,,2);
s1d=s(i1).’;
clear d1
%decision for detecting s2
[y2,i2]=min(d2,,2);
s2d=s(i2).’;
clear d2
% form received symbols
Xd=[s1d s2d];
%determine symbol errors
error_un(packet_count)=sum(X(:,1)~=s0d);% for uncoded
temp1=X》0;
temp2=Xd》0;
error(packet_count)=sum(sum(temp1~=temp2));% for coded
end % end of FOR loop for “packet_count“
%calculate FER, SER and BER for current idx
%for uncoded signal
SER_uncoded(idx)=sum(error_un)/(Num*K);
BER_uncoded(idx)=SER_uncoded(idx)/BIT;
FER_uncoded(idx)=SER_uncoded(idx)*K;
%for coded signal
SER(idx)=sum(error)/(Num*K);
BER(idx)=SER(idx)/BIT;
FER(idx)=SER(idx)*K;
%increment idx
idx=idx + 1;
str_bar=[num2str(wb) ’% Completed’];
waitbar(wb/100,h,str_bar);
wb=wb+9.09;
end % end of FOR loop for SNR
close(h);
%%%%%%%以下是tx_modulate的function.m
function [mod_symbols,table, P] = tx_modulate(bits_in, modulation)
%**************************************************************************
%This program modulates the input binary data.The inputs are:
% bits_in -》 the binary input bits
%modulation -》 we choose one of ’BPSK’,’QPSK’,8PSK’,16QAM’
%The outputs are:
%mod_symbols -》 modulated output
%table -》 the complete set of symbols in a chosen constellation. This is
%required by the demodulator.
%P -》 the number of points in a chosen constellation. This is required by
%the demodulator
%**************************************************************************
full_len = length(bits_in);
% BPSK modulation
if ~isempty(findstr(modulation, ’BPSK’))
% Angle [pi/4 -3*pi/4] corresponds to
% Gray code vector [0 1], respectively.
table=exp(j*[0 -pi]); % generates BPSK symbols
table=table([1 0]+1); % Gray code mapping pattern for BPSK symbols
inp=bits_in;
mod_symbols=table(inp+1); % maps transmitted bits into BPSK symbols
P=2;% 2 constellation points
% QPSK modulation
elseif ~isempty(findstr(modulation, ’QPSK’))
% Angle [pi/4 3*pi/4 -3*pi/4 -pi/4] corresponds to
% Gray code vector [00 10 11 01], respectively.
table=exp(j*[-3/4*pi 3/4*pi 1/4*pi -1/4*pi]); % generates QPSK symbols
table=table([0 1 3 2]+1); % Gray code mapping pattern for QPSK symbols
inp=reshape(bits_in,2,full_len/2);
mod_symbols=table([2 1]*inp+1); % maps transmitted bits into QPSK symbols
P=4;% 4 constellation points
elseif ~isempty(findstr(modulation, ’8PSK’))
% generate constellations
% Angle [0 pi/4 pi/2 3*pi/4 pi 5*pi/4 3*pi/2 7*pi/4] corresponds to
% Gray code vector [000 001 011 010 110 111 101 100], respectively.
table=exp(j*[0 pi/4 pi/2 3*pi/4 pi 5*pi/4 3*pi/2 7*pi/4]); % generates 8PSK symbols
table=table([0 1 3 2 6 7 5 4]+1); % Gray code mapping pattern for 8PSK symbols
inp=reshape(bits_in,3,full_len/3);
mod_symbols=table([4 2 1]*inp+1); % maps transmitted bits into 8PSK symbols
P=8;%8 constellation points
% 16-QAM modulation
elseif ~isempty(findstr(modulation, ’16QAM’))
% generates 16QAM symbols
m=1;
for k=-3:2:3
for l=-3:2:3
table(m) = (k+j*l)/sqrt(10); % power normalization
m=m+1;
end;
end;
table=table([0 1 3 2 4 5 7 6 12 13 15 14 8 9 11 10]+1); % Gray code mapping pattern for 8-PSK symbols
inp=reshape(bits_in,4,full_len/4);
mod_symbols=table([8 4 2 1]*inp+1); % maps transmitted bits into 16QAM symbols
P=16; %16 constellation points
else
error(’Unimplemented modulation’);
end
希望能有帮助!
瑞利信道怎么用 matlab做仿真
如果是最简单的平坦瑞利衰落,将星座图映射后的信号,乘以功率为1的复高斯信号就完成了。在接收端判决前,除以信道系数(即前边的复高斯信号),就可以判决了。这样肯定是0误码率。在加入衰落后,还可以加入不同功率的白噪声,进而得到SNR-BER曲线.
如果多径,还要在接收端引入均衡,均衡有很多种。
可以看看simulink中自带的例子
瑞利衰落信道仿真分析(matlab)首先设一条AWGN信道只含直射路径,逐渐增加多径分量
饿了。 。 。
您的H1确实是瑞利分布,但幅度通道H1啊,我们说“瑞利路”,不意味着真正的通道,而是一个复杂的通道,通道幅度瑞利分布,所以你H1 = ABS( H1)“这句话应该被删除。
其次,就是我们常说的信道响应,不包含??高斯白噪声,也就是说,只H此人。
直接IFFT(H1 )是信道响应。************************************
建模许多通信模块失败的反映,说明这里也不是很清楚。建议向老师

更多文章:
another time(another time和other time的区别)
2026年10月11日 05:00







