for sim_index = 1:Len
Psn = snrVec(sim_index);
snr = 10^(Psn/10);
A_PPM = sqrt(snr*2);
for loops = 1:IterNum
Source = randi([0,1],1,BitNum);
codec_out = convenc(Source,Trellis);
% OOK modulation
Sym_OOK = codec_out;
% waveform shaping
Tx_OOK = WaveForm(Sym_OOK,SamplePerSym*SymbolNum*2);
% get the oversample factor
n_PPM = length(Tx_OOK)/length(Sym_OOK);
% additive noise channel 这里添加一些干扰控制
noise = randn(1,length(Tx_OOK));
Rec_OOK = A_PPM*Tx_OOK + noise(1:length(Tx_OOK));
% decision
Dec_OOK = Hard_Decision(Rec_OOK,n_PPM,Threshold);
% decode
Sink_OOK = VLC_Decode('OOK',Dec_OOK,1);
% decoder
DecoderOut = vitdec(Sink_OOK,Trellis,TraceLen,'trunc','hard');
% ber for PPM
[~,ber] = biterr(DecoderOut,Source);
BER(1,sim_index) = BER(1,sim_index) + ber;
% PER
if(ber)
PER(1,sim_index) = PER(1,sim_index) + 1;
end
end % loop for iteration
end % loop for Psn