timingerrorberplotter.m

来自「这是一个关于完成QAM调制的Matlab示例程序」· M 代码 · 共 70 行

M
70
字号
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This script plots data generated by GenMatchedFilterTimingErrorBerData.  This
% script assumes the data saved by that function is already present in the workspace.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%Perform plotting
figure;
% Plot AWGN values
%subplot(2,1,1);
%hold ontimingIndex = 1;
for timingError = timingRange(1):timingRange(3):timingRange(2)
    gammaMaxSimulated = gammaRangeAwgn(2);
    for gammaMaxSimulatedIndex = 1:gammaSamplesAwgn
        if (ber(gammaMaxSimulatedIndex,timingIndex,2,1) == 0)
            % That's the flag for data value that wasn't calculated.  So, back up one
            % Not the greatest programming style to mess with the counter value in the middle
            % of the loop, but this gets the job done.
            gammaMaxSimulatedIndex = gammaMaxSimulatedIndex - 1;
            gammaMaxSimulated = gammaRangeAwgn(1) + (gammaMaxSimulatedIndex - 1)*gammaRangeAwgn(3);
            break;
        end
    end
    semilogy([gammaRangeAwgn(1):gammaRangeAwgn(3):gammaRangeAwgn(2)],ber(1:gammaSamplesAwgn,timingIndex,1,1),'b-',...
        [gammaRangeAwgn(1):gammaRangeAwgn(3):gammaRangeAwgn(2)],ber(1:gammaSamplesAwgn,timingIndex,1,1),'bo',...
        [gammaRangeAwgn(1):gammaRangeAwgn(3):gammaMaxSimulated],ber(1:gammaMaxSimulatedIndex,timingIndex,2,1),'k-.',...
        [gammaRangeAwgn(1):gammaRangeAwgn(3):gammaMaxSimulated],ber(1:gammaMaxSimulatedIndex,timingIndex,2,1),'k+');
    hold on;
    timingIndex = timingIndex + 1;
end
%title(['BER vs Es/N0 In AWGN, No Fading.  timing error, from top to bottom = ',num2str(timingRange(2):-timingRange(3):timingRange(1)),' radians']);
title(['BER vs Es/N0 In AWGN, No Fading.  Has matched filter timing error.']);
xlabel('Es/N0 (dB)');
ylabel('BER');
legend('','Theoretical','','Simulated',3);
hold off% Plot Rayleigh values
%subplot(2,1,2);
%hold on
figure
timingIndex = 1;
for timing = timingRange(1):timingRange(3):timingRange(2)    gammaMaxSimulated = gammaRangeRayleigh(2);
    for gammaMaxSimulatedIndex = 1:gammaSamplesRayleigh
        if (ber(gammaMaxSimulatedIndex,timingIndex,2,2) == 0)
            % That's the flag for data value that wasn't calculated.  So, back up one
            % Not the greatest programming style to mess with the counter value in the middle
            % of the loop, but this gets the job done.
            gammaMaxSimulatedIndex = gammaMaxSimulatedIndex - 1;
            gammaMaxSimulated = gammaRangeRayleigh(1) + (gammaMaxSimulatedIndex - 1)*gammaRangeRayleigh(3);
            break;
        end
     end    semilogy([gammaRangeRayleigh(1):gammaRangeRayleigh(3):gammaRangeRayleigh(2)],ber(1:gammaSamplesRayleigh,timingIndex,1,2),'b-',...
        [gammaRangeRayleigh(1):gammaRangeRayleigh(3):gammaRangeRayleigh(2)],ber(1:gammaSamplesRayleigh,timingIndex,1,2),'bo',...
        [gammaRangeRayleigh(1):gammaRangeRayleigh(3):gammaMaxSimulated],ber(1:gammaMaxSimulatedIndex,timingIndex,2,2),'k-.',...
        [gammaRangeRayleigh(1):gammaRangeRayleigh(3):gammaMaxSimulated],ber(1:gammaMaxSimulatedIndex,timingIndex,2,2),'k+');
    hold on;
    timingIndex = timingIndex + 1;
end
title(['BER vs Es/N0 In AWGN, With Rayleigh Fading.  Has matched filter timing error.']);
xlabel('Es/N0 (dB)');
ylabel('BER');
legend('','Theoretical','','Simulated',3);
hold off

⌨️ 快捷键说明

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