Expected input to be a scalar.

4 views (last 30 days)
amani
amani on 9 Jul 2024
Moved: Torsten on 9 Jul 2024
this is my cod , i have problem at this ligne :
ofdm_symb_awgn_t=ifft(awgn( fft(ofdm_symb_t) , SNR, 'measured'));
close all;
clear all;
%% Ofdm parameteres %%
mod_order = 4; % Oder da modulaQAM
N =256; % Numero de sinais a ser modulado/tamaho do ODFDM symbol
vec_EbN0_dB_ofdm =0 : 2 : 20 ;
vec_SNR_dB_ofdm = vec_EbN0_dB_ofdm + 10 * log10( mod_order );
%SNR=18;
fading= 'yes';
for i=1:length(vec_EbN0_dB_ofdm)
var_ber_soma = 0;
var_ber(i) = 0;
iteracao = 0;
SNR(i) = vec_EbN0_dB_ofdm(i)+ 10*log10( log2(mod_order)) ;
while(var_ber_soma < 100)
i
iteracao = iteracao + 1
%tx
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);
if strcmpi(fading,'yes')
%Rayleigh channel
h = (randn+1i*randn)/sqrt(2);
H=fft(h, N).';
rayleigh_ofdm_symb= H .* qam_symb_tx_f;
elseif strcmpi(fading,'no')
h = 1;
H=fft(h, N).';
rayleigh_ofdm_symb= H .* qam_symb_tx_f;
end
%Adding AWGN / tem que ser na freq?
ofdm_symb_awgn_t=ifft(awgn( fft(ofdm_symb_t) , SNR, 'measured'));
ofdm_symb_awgn= awgn(rayleigh_ofdm_symb , SNR(i));%, 'measured');
%rx
%data_rx=qamdemod((ofdm_symb_awgn./H),mod_order, 'UnitAveragePower', true);
data_rx=qamdemod((ofdm_symb_awgn),mod_order, 'UnitAveragePower', true);
%SER
ser= sum(data_tx~=data_rx);
[SnumErrors,ser2] = symerr(data_tx,data_rx);
%BER
[BnumErrors, ber] = biterr(data_tx,data_rx);
var_ber_soma = var_ber_soma + ber
%var_ser(i) = ser2;
end
var_ber(i) = var_ber_soma/iteracao;
end
%semilogy(SNR,var_ber, 'r', 'MarkerSize', 2 );
semilogy(SNR,var_ber, 'c', 'MarkerSize', 3 );
ylim( [ 1e-6, 10000 ] ); xlim( [ 0, 20 ] );
grid on;
hold on ;

Answers (1)

Torsten
Torsten on 9 Jul 2024
Moved: Torsten on 9 Jul 2024
%Adding AWGN / tem que ser na freq?
ofdm_symb_awgn_t=ifft(awgn( fft(ofdm_symb_t) , SNR, 'measured'));
ofdm_symb_awgn= awgn(rayleigh_ofdm_symb , SNR(i));%, 'measured');
In the first line, you most probably mean SNR(i) instead of SNR.

Categories

Find more on Propagation and Channel Models in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!