基于matlab实现空时分组编码 2 Tx 1 Rx

✅作者简介:热爱科研的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电子书和数学建模资料

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值