I want to draw all three different tau_rms values in one picture ,tau_rms = 10*10^(-9), 30*10^(-9), 100*10^(-9), SNR = 30
    3 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
No_PKT = 3000;                          % Number of packets for simulation
NSYM_PKT = 50;                          % Number of OFDM symbols in a packet for information data
FFT_SIZE = 64;                          % FFT size
BW = 20 * 10^(6);                       % System bandwidth, 20MHz, fixed
Ts = 1/BW;                              % Sampling interval in second unit
GI_LEN = 16;                            % Guard interval in Ts unit, fixed
subcarrier_spacing = 1/(FFT_SIZE * Ts); % Subcarrier spacing in Hz unit
N_data_subcarrier = 48;                 % Number of data subcarriers, fixed
N_pilot_subcarrier = 4;                 % Number of pilot subcarriers, fixed
pilot = [1 1 -1 1];                     % pilot symbols
modulation = '16QAM';                    % BPSK, QPSK, 16QAM, 64QAM
%===================================== Channel Environments ======================================
Channel_type = 'Rayleigh';             % 'Rayleigh' for Rayleigh channel and 'AWGN' for AWGN channel
Ch_est_mode = 'LS';                  % 'Perfect' for perfect channel estimation, 'MMSE', 'LS'                          
%============================= MMSE filter parameters ==============================
SNR_MMSE = 30;                         % SNR for MMSE filter in dB
beta = 1;                              % beta = E[x^2] * E[1/x^2]
tau_rms = 100 * 10^(-9);                % rms delay for MMSE filter in second unit  
%=================================================================================== 
SNR = [10: 2: 30];                     % SNR or Es/No for simulation
switch Channel_type
    case 'AWGN'
        No_Path = 1;
        PATH_DELAY = 0;                   % Relative delay in nano second unit
        PATH_GAIN = 0;                    % in dB        
    case 'Rayleigh'
        No_Path = 4;                             % Number of multi-paths
        PATH_DELAY = [0, 50, 200, 350];          % Relative delays in nano second unit
        PATH_GAIN = [0, -5.4, -10.3, -17.6];     % Relative gains in dB unit, 33ns 
        PATH_DELAY = round( PATH_DELAY * 10^(-9) / Ts); % Relative delays in Ts unit
end
switch modulation
    case 'BPSK'
        Mod_level = 1;
        normalize_factor = 1;
    case 'QPSK'
        Mod_level = 2;
        normalize_factor = sqrt(2);
    case '16QAM'
        Mod_level = 4;
        normalize_factor = sqrt(10);
    case '64QAM'
        Mod_level = 6;
        normalize_factor = sqrt(42);       
end
% MMSE filter generation based on exponential delay profile models
[MMSE_filter] = MMSE( SNR_MMSE, tau_rms, subcarrier_spacing, beta );
[preamble ifft_input_LTS ] = preamble_gen( FFT_SIZE );  % preamble generation
length_preamble = length(preamble);
for isnr = 1 : length(SNR)             % loop for SNR or Es/No
    Es = 10 ^ ( SNR(isnr) / 10 );      % symbol energe in linear scale
    seed = 1;
    randn('seed',seed);
    bit_err_total = 0;   
    for ifn = 1 : No_PKT                % loop for packet
        data = randn(1, N_data_subcarrier * NSYM_PKT * Mod_level) > 0; % binary data generation for each packet
        % symbol mapping and frame formating by modulation level
        [ifft_input] = symbol_mapping( data, pilot, FFT_SIZE, N_data_subcarrier, NSYM_PKT, Mod_level, normalize_factor );       
        % Inverse FFT
        [ifft_sig] = inverse_fft( ifft_input, FFT_SIZE, NSYM_PKT );
        % Guard insertion and parallel to serial conversion
        [tx_sig] = guard_insertion( ifft_sig, FFT_SIZE, NSYM_PKT, GI_LEN );
        tx_sig = [ preamble tx_sig ]; %cascading preamble and ofdm signals
        % Generating fading signals
        [fade] = fading_gen( Channel_type, PATH_GAIN, PATH_DELAY );
        % Generating a received signal 
        [rx_sig, rx_sig_no_noise] = rx_sig_gen( tx_sig, fade, Es, FFT_SIZE, GI_LEN, NSYM_PKT, length_preamble, Ts );
        % Guard removal
        [guard_removed_sig, guard_removed_sig_no_noise, guard_removed_LTS] = guard_removal( rx_sig, rx_sig_no_noise, FFT_SIZE, NSYM_PKT, GI_LEN );            
        % FFT at the receiver
        [fft_sig, fft_sig_no_noise, fft_LTS] = forward_fft( guard_removed_sig, guard_removed_sig_no_noise, guard_removed_LTS, FFT_SIZE, NSYM_PKT );
        % Channel estimation
        [est_channel] = channel_est( fft_LTS, ifft_input_LTS, fft_sig_no_noise, ifft_input, Ch_est_mode, MMSE_filter, NSYM_PKT );
        % Channel compensation and symbol demapping
        [est_data] = symbol_demapping( fft_sig, est_channel, NSYM_PKT, Mod_level, normalize_factor );
        % Counting the number of error bits
        bit_err = sum(data ~=est_data);
        bit_err_total = bit_err_total + bit_err;
        if  mod(ifn, 10) == 0
            Accumulated_BER = bit_err_total / ( N_data_subcarrier * NSYM_PKT * Mod_level * ifn )
        end  
    end   
    BER(isnr) = bit_err_total / (N_data_subcarrier * NSYM_PKT * Mod_level * No_PKT) 
end
semilogy(SNR,BER,'r-o');
xlabel('Es/No (dB)');
ylabel('BER');
axis([10 30 10^(-4) 10^(0)]);
grid on
0 commentaires
Réponses (1)
  Pratyush Swain
      
 le 31 Août 2023
        Hey zoop,
You can find a detailed approach to your issue here – https://in.mathworks.com/matlabcentral/answers/1840038-how-can-i-put-three-different-tau_rms-in-this-code-and-draw-them-in-one-picture-each-tau_rms-5-1?s_tid=answers_rc1-1_p1_BOTH.
In place of the tau rms values mentioned in the solution above, you can substitute your relevant tau values. 
Hope this helps.
0 commentaires
Voir également
Catégories
				En savoir plus sur Propagation and Channel Models dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

