✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
本文介绍了空时分组码的编解码原理,并给出了空时分组码编译码器的MATLAB实现代码,最后对空时分组码的性能进行了仿真,仿真结果显示空时分组码具有良好的发射分集和接收分集性能.
⛄ 部分代码
clear all
close all
clc
N=1; % Number of bits per symbol
ModType='PSK'; % either PSK or QAM
M=2^N; % Number of possible symbols
ES=1; % Energy of symbol
ESg=ES/2; % Because of two antennas (separate energy)
LS=3e4; % Length of symbol stream
LB=LS*N; % Length of Bit stream
%%Parameters
EB=ES/N; % Energy of Bit
EBN0dB=0:15; % EB/N0 in dB
ESN0dB=EBN0dB+10*log10(N); % ES/N0 in dB
EBN0=10.^(EBN0dB/10); % EB/N0
ESN0=10.^(ESN0dB/10); % ES/N0
N0=ES./ESN0; % Noise Density
Variance=N0./2; % Variance of Noise
StandardD=sqrt(Variance); % Standard deviation of Noise
Mean=0; % Mean of Noise
%% Generating Constallation symbol
[S] = AllModTypes(ModType,ESg,N);
BER=[]; % Simulated BER will be stored in this empty matrix
for kk=1:length(EBN0dB)
kk
%% Generating random stream of bits
Bits=randi([0 1],1,LB);
%% Converting Bit stream from serial to prallel to produce symbols
PBits=reshape(Bits,N,LS);
%% Conveting the parallel bits into decimal to sellect symbols from constellation symbols
deN=bi2de(PBits')'; % decimal numbers
TS=S(deN+1); % transmitting symbols
% %% Normalising the transmitting power dividing over number of transmitting antennas
% TS=TS/2;
%% Generating fading coefficient with length equal 0.5 * length of Transmitting symbol
% since, it's fixed for the duration of two symbols
h11 =1/sqrt(2)*[randn(1,LS/2) + j*randn(1,LS/2)]; % fading coefficient between Tx1 and RX
h21 =1/sqrt(2)*[randn(1,LS/2) + j*randn(1,LS/2)]; % fading coefficient between Tx2 and RX
% extending it to the length of stream
Temp11=zeros(1,LS);
Temp11(1:2:end)=h11;
Temp11(2:2:end)=h11;
% fading coeff?c?ent between Tx1 and RX with length equal LS
% 2 adjacent fady?ng are the same (fixed for two symbols)
Temp21=zeros(1,LS);
Temp21(1:2:end)=h21;
Temp21(2:2:end)=h21;
% fading coefficient between Tx1 and RX with length equal LS
%% STBC mapping
% maping for antenna number 1
TX1=TS;
TX1(2:2:end)=-conj(TX1(2:2:end)); % Transmitting stream from antenna 1
% maping for antenna number 1
TX2=TS;
TX2(1:2:end)=TS(2:2:end);
TX2(2:2:end)=conj(TS(1:2:end)); % Transmitting stream from antenna 1
%% Applying Fading coefficient on transmitting stream
%% without Noise
a=TX1.*Temp11;
b=TX2.*Temp21;
R=a+b; % Received Stream by one Receive antenna
%%%%%%%%%%%%%%%%%%%%%%%%% Generating Noise
Noise=sqrt(N0(kk)/2).*(randn(1,LS)+1j*(randn(1,LS)));
%%%%%%%%%%%%%%%%%%%%%%%%%% adding Noise at the reciver side
R=R+Noise;
%% separate first and second time instants received symbols
R1=R(1:2:end);
R2=R(2:2:end);
%% detecting again stream of symbols by inversly applying fading coefficients (with noise)
R11=conj(h11).*R1./(abs(h11).^2+abs(h21).^2);
R21=conj(R2).*h21./(abs(h11).^2+abs(h21).^2);
S1=R11+R21;
R11=-h11.*conj(R2)./(abs(h11).^2+abs(h21).^2);
R21=R1.*conj(h21)./(abs(h11).^2+abs(h21).^2);
S2=R21+R11;
% Received stream
RStream=ones(1,LS);
RStream(1:2:end)=S1;
RStream(2:2:end)=S2;
%% Passing the received signal into maximum likelyhood receiver
R=RStream;
Loc=[];
for kk=1:LS
D=abs(R(kk)-S); % Distances between R and all symbols
MinD=min(D); % min Distance
LminD=find(D==MinD); % Location of minimum Distance
Loc=[Loc LminD]; % Location of all symbol stream
end
RB=reshape(de2bi(Loc-1,N)',1,N*LS); % Received Bits
BER=[BER (sum(abs(RB-Bits)))/(N*LS)]; % Bit Error rate
R=TS;
end
semilogy(EBN0dB, BER,'-*') %Plot the BER
hold on
xlabel('EbNo(dB)') %Label for x-axis
ylabel('BER') %Label for y-axis
grid on %Turning the grid on
axis([EBN0dB(1) EBN0dB(end) 10^-4 1])
⛄ 运行结果
⛄ 参考文献
[1] 吴军, 吴小波, 刘田,等. Alamouti空时分组码的MATLAB仿真与FPGA实现[J]. 电视技术, 2012, 36(17):4.
[2] 王安国, 沈琼, 聂仲尔. 基于准正交空时分组码的高速率码字设计[J]. 通信学报, 2011, 32(2):6
❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料