vec_EbN0_dB_ofdm =0 : 2 : 20 ;
vec_SNR_dB_ofdm = vec_EbN0_dB_ofdm + 10 * log10( mod_order );
for i=1:length(vec_EbN0_dB_ofdm)
SNR(i) = vec_EbN0_dB_ofdm(i)+ 10*log10( log2(mod_order)) ;
while(var_ber_soma < 100)
data_tx = randi([0,mod_order-1],N,1);
qam_symb_tx_f=qammod(data_tx,mod_order, 'UnitAveragePower', true);
ofdm_symb_t=ifft(qam_symb_tx_f, N);
h = (randn+1i*randn)/sqrt(2);
rayleigh_ofdm_symb= H .* qam_symb_tx_f;
elseif strcmpi(fading,'no')
rayleigh_ofdm_symb= H .* qam_symb_tx_f;
ofdm_symb_awgn_t=ifft(awgn( fft(ofdm_symb_t) , SNR, 'measured'));
ofdm_symb_awgn= awgn(rayleigh_ofdm_symb , SNR(i));
data_rx=qamdemod((ofdm_symb_awgn),mod_order, 'UnitAveragePower', true);
ser= sum(data_tx~=data_rx);
[SnumErrors,ser2] = symerr(data_tx,data_rx);
[BnumErrors, ber] = biterr(data_tx,data_rx);
var_ber_soma = var_ber_soma + ber
var_ber(i) = var_ber_soma/iteracao;
semilogy(SNR,var_ber, 'c', 'MarkerSize', 3 );
ylim( [ 1e-6, 10000 ] ); xlim( [ 0, 20 ] );