⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c105p_mcqpskber_1.m

📁 使用pMatlab改写BPSK和QPSK 的Monte Carlo 仿真程序。在多核PC上实现MC仿真速度翻倍(附原程序)
💻 M
字号:
t=cputime;
Eb=22:0.5:26;No=-50                 %Eb(dBm) and No(dBm/Hz)
ChannelAttenuation=70               %Channel attenuation in dB
EbNodB=(Eb-ChannelAttenuation)-No;  %Eb/No in dB
EbNo=10.^(EbNodB./10);              %Eb/No in linear units
BER_T=0.5*erfc(sqrt(EbNo));         %BER (theor)
N=round(300./BER_T);                %Symbols to transmit

% Turn parallelism on or off.
PARALLEL = 1;

% Create Maps.
map1 = 1;
if (PARALLEL)
    % Initialize pMatlab.
    pMatlab_Init;
    Ncpus = pMATLAB.comm_size;
    my_rank = pMATLAB.my_rank;

    % Break up rows.
    map1 = map([Ncpus 1], {}, 0:Ncpus-1 );
end

%Creat'Errors'-error number output matrix,'BER'-BER simulation output
%matrix
BER_MC=zeros(Ncpus,length(Eb),map1);     %initialize BER vector
N_p=round(N/Ncpus);

% Get the local portion of the global indices
my_i_global = global_ind(BER_MC, 1);
% Get the local portion of the distributed matrix
my_BER_MC=local(BER_MC);

for i_local=1:length(my_i_global)
    %Determine the global No. of symbols for this (local) iteration
    i_global=my_i_global(i_local);
    
    %Loop over the local indices
    for j=1:length(Eb)
        my_BER_MC(i_local,j)=c10_MCQPSKrun(N_p(j),Eb(j),No,...
        ChannelAttenuation,0,0,0,0);
        disp(['Simulation',num2str(j*100/length(Eb)),'%Complete']);
    end; % of j
end % of i_local

%Store the local portion of BER_MC into the dmat 'BER_MC'
BER_MC=put_local(BER_MC,my_BER_MC);

%Finally, aggregate all of the output onto the leader process
BER_MC_final=agg(BER_MC);
BER_MC_avg=zeros(1,length(Eb));

for j=1:length(Eb)
    BER_MC_avg(1,j)=sum(BER_MC_final(:,j))/Ncpus
end;

% Finalize the pMATLAB program
if (PARALLEL)
    disp('SUCCESS_Parallel');
    pMatlab_Finalize;
end

% Finally, display the resulting matrix on the leader
disp(BER_MC_final);
semilogy(EbNodB,BER_MC_avg,'o',EbNodB,2*BER_T,'-r')
xlabel('Eb/No(dB)');ylabel('Bit Error Rate');
legend('MC BER Estimate','Theoretical BER');grid;
e=cputime-t;
disp(e);
%End

⌨️ 快捷键说明

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