• BPSK相干解调和DBPSK非相干解调误码率仿真


    BPSK相干解调和DBPSK非相干解调误码率仿真

    本脚本完成了BPSK和DBPSK两种不同调制方式下的误码率(DBPSK差分相干)仿真, 并和理论曲线进行了对比。

      撰写人:***
      最后修改日期:2015-03-18
      软件版本:MATLAB(R) 2014a

    程序添加和修改包括

    1. BPSK未作修改
    2. DPSK添加了成型部分,同时从《高等数字通信》中看到了DPSK最佳接收机的结构

    待改进

    1. 怎样选择仿真点数才能保证结果可信,可信程度是多少?如何衡量?

    Contents

    初始设置

    清空工作区,数据,关闭所有窗口

    clc;clear all;close all;

    仿真参数设置

    EbN0_dB = 1:8;                            % EbN0_dB 误码率范围,向量;
    FRAMES_NUM = 100;                         % FRAMES_NUM 最大仿真帧数目;
    FRAMES_LENGTH = 1000;                     % FRAMES_LENGTH 每帧长度;
    UPSAMPLE_RATE = 8;                        % UPSAMPLE_RATE 过采样率;
    berBpsk = zeros(1,length(EbN0_dB));       % berBpsk BPSK误码率统计,向量;
    berDbpsk = zeros(1,length(EbN0_dB));      % berDbpsk DBPSK误码率统计,向量;
    sqrtRaisedfilter = rcosfir(0.3,[-3,3],UPSAMPLE_RATE,1,'sqrt');

    误码率仿真

    针对不同EbN0先仿真BPSK和DBPSK误码率曲线

    在不同EbN0下,对误码率进行仿真

    for nEbN0 = 1:length(EbN0_dB);

    多帧取统计平均

        bpskErrorNum = 0;
        dbpskErrorNum = 0;
        for nFrame = 1:FRAMES_NUM

    数据生成和基带映射

            data = randi([0 1],1,FRAMES_LENGTH);
            bpskBaseband = 1 - 2*data;          % 映射 0—+1;1—-1,已归一化
            data_extend = [1 data];             % 差分编码,假设第一个数据为1
            for num = 2:FRAMES_LENGTH+1
                data_extend(num) = xor(data_extend(num),data_extend(num-1));
            end
            % 注意此时DBPSK多传了一个1
            dbpskBaseband = 1 - 2*data_extend;  % 映射 0—+1;1—-1,已归一化
            % 方波成型
            %dbpskBaseband = reshape(repmat(dbpskBaseband,UPSAMPLE_RATE,1),1,[]);
            % 匹配滤波
            dbpskBaseband = upsample(dbpskBaseband,UPSAMPLE_RATE);
            dbpskBaseband = conv(dbpskBaseband,sqrtRaisedfilter,'same');
            bpskTransmitSignal = bpskBaseband;  % 不加载波
            dbpskTransmitSignal = dbpskBaseband/sqrt(var(dbpskBaseband));

    AWGN 信道,SNR和EbN0换算关系

    BPSK_DBPSK_V2_eq30691

            SNR_dB = EbN0_dB(nEbN0) + 10*log10(2) - 10*log10(1);
            SNR = 10^(SNR_dB/10);

    接收信号的矢量等效

            bpsknoise = 1/sqrt(SNR)*randn(1,length(bpskTransmitSignal));
            bpskReceiveSignal = bpskTransmitSignal + bpsknoise;
            SNR_dB = EbN0_dB(nEbN0) + 10*log10(2) - 10*log10(UPSAMPLE_RATE);
            SNR = 10^(SNR_dB/10);
            dbpsknoise =  1/sqrt(SNR)*randn(1,length(dbpskTransmitSignal)) + ...
                1i*1/sqrt(SNR)*randn(1,length(dbpskTransmitSignal));
            dbpskReceiveSignal = dbpskTransmitSignal + dbpsknoise;

    BPSK误比特数统计

            bpskErrorNum = bpskErrorNum + sum(bpskBaseband.*bpskReceiveSignal<0);

    DBPSK解调(通信原理P209) 误比特数统计,不是最佳接收 方波成型解调如果UPSAMPLE_RATE为1,此时能使用sum函数

            %dbpskReceiveSignal = sum(reshape(dbpskReceiveSignal,UPSAMPLE_RATE,[]));
            % 匹配滤波解调
            dbpskReceiveSignal = conv(dbpskReceiveSignal,sqrtRaisedfilter,'same');
            dbpskReceiveSignal = downsample(dbpskReceiveSignal,UPSAMPLE_RATE);
            dbpskDelay = dbpskReceiveSignal(2:end);
            dbpskJudgment = dbpskReceiveSignal(1:end-1).*dbpskDelay;
            dbpskDecodeData = zeros(1,length(data));
            dbpskDecodeData(dbpskJudgment<0) = 1;   %gt compares only the real part
            dbpskErrorNum = dbpskErrorNum + sum(abs(dbpskDecodeData-data));
        end

    误码率统计

        berBpsk(nEbN0) = bpskErrorNum/FRAMES_NUM/FRAMES_LENGTH;
        berDbpsk(nEbN0) = dbpskErrorNum/FRAMES_NUM/FRAMES_LENGTH;
    end

    绘图和数据输出

    绘制BPSK和DBPSK的仿真和理论误码率曲线

    berBpskTheory = berawgn(EbN0_dB,'psk',2,'nondiff');
    berDbpskTheory = berawgn(EbN0_dB,'dpsk',2,'nondiff');
    fprintf('总帧数 = %d,帧长 = %d
    ',FRAMES_NUM,FRAMES_LENGTH);
    table(EbN0_dB',berBpskTheory',berBpsk',berDbpskTheory',berDbpsk',...
        'VariableNames', {'EbN0_dB','BpskTheory','BpskSim','DbpskTheory','DbpskSim'})
    
    figure;
    semilogy(EbN0_dB,berDbpsk,'bd');hold on;
    semilogy(EbN0_dB,berDbpskTheory,'b-');
    semilogy(EbN0_dB,berBpsk,'rs');
    semilogy(EbN0_dB,berBpskTheory,'r-');hold off;
    legend('差分DPSK仿真','DPSK理论','相干BPSK仿真','相干BPSK理论');
    xlabel('EbN0');
    ylabel('BER');
    grid on;
    总帧数 = 100,帧长 = 1000
    
    ans = 
    
        EbN0_dB    BpskTheory    BpskSim    DbpskTheory    DbpskSim
        _______    __________    _______    ___________    ________
    
        1            0.056282    0.05494      0.14198      0.14132 
        2            0.037506    0.03737      0.10248      0.10291 
        3            0.022878    0.02259     0.067989      0.06888 
        4            0.012501    0.01247     0.040558      0.03912 
        5           0.0059539     0.0061     0.021165      0.02151 
        6           0.0023883     0.0024    0.0093328      0.00937 
        7          0.00077267    0.00079    0.0033292      0.00334 
        8          0.00019091    0.00022    0.0009094      0.00076 
    BPSK_DBPSK_V2_01
    允许自由转载,无需注明出处 博客由word编写,上传后排版略乱,请谅解
  • 相关阅读:
    常见的等待事件如何处理
    oracle常见的等待事件
    12c建立物化视图出现ORA-23319错误
    ORA-07445: exception encountered: core dump [qsmmixGetIdxKeyStats()+231] [SIGSEGV] [ADDR:0x8] [PC:0x58AE44F] [Address not mapped to object] []
    Idea的Debug调试快捷键
    C# 程序禁止重复启动
    C#.Net与SQLServer时间范围的最小值最大值
    MySQL-8.0.20
    Flask框架
    Docker常用命令
  • 原文地址:https://www.cnblogs.com/sea-wind2/p/4369254.html
Copyright © 2020-2023  润新知