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

📄 main.m

📁 一些关于空时编码的编码解码仿真程序
💻 M
字号:
function main
clear;
clc
warning off
%%%%%%%%%%%%%%%%%%%%%
[K,D,N,G,N_t,N_r,L,C]= header;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SNR =14;
loop =1000;
for snr = 0:2:SNR,

%   snr = 5     
%     [power_d,power_p] = power_header(snr);
     noise =10^(-snr/10); 
    for lp = 1:loop,
        disp(['snr--loop:   ',num2str([snr lp])]);
        %%%%%%%%%%%%%%%%%%%%%to generate channel%%%%%%%%%%%%%%

        
        %generate bits with dim.  1by 2*D*N(aiming Qpsk)
        [source_out] = source;
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %channel conv. coding
%         [Ch_conv_out] = ChannelConvCoding(source_out);
%         [I_l_out,IX_IL] = interleaving(Ch_conv_out);
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %modulation
        [Mod_out] = Modulation(source_out);
        %STBC coding 
        [STBC_out] = STBC(Mod_out);
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %i_l_out: 
        [IX_IL] = gen_il;
        [i_l_out] = interleaving(st_out,IX_IL);
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %combination of pilot and data symbols
        %
%         [Cmb_pilot_out] = CombinePiotData(STBC_out,PILOT);
%         [Cmb_ce_out] = CombineChannelEstimeData(Cmb_pilot_out,CE_gen_out);
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %OFDM IFFT processing
        %ofdm_out dimension:
%         [ofdm_out] = ofdm(Cmb_pilot_out);
%         [Over_sample_out] = OverSampling(ofdm_out,IPOINT);
%         [TxConv_out] = PerformConv(Over_sample_out,Tx_filter_parameter);
%         [G_ins_out]= GuardIntervalInsertion(ofdm_out,1);
        %---------- Attenuation Calculation ----------
% 		spow=sum(sum(abs(G_ins_out).^2))/(K*N_r*(N+2));
% 		attn=sqrt(spow/2*10^(-snr/10));
% 
%         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%         %pass channel     %ch_out:         %ideal_ch:
%         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        [Ch_out,Real_ch_f] = PassChannel(G_ins_out,Ch_time_out,Time_Sample_out,T_s);
        %add Gaussian noise
        %noised_out: N_r by K by N; 
         
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%         [G_rmv_out] = GuardIntervalRemoval(Ch_out,1);
        spow = sum(sum(sum(abs(G_rmv_out).^2)))/((K)*N_r*N);
	    attn = spow*10^(-snr/10);
        [noised_out] = add_gauss_noise(G_rmv_out, noise);
%        
        
        
        %FFT processing
        %fft_out :N_r * K by N;
%         [Rx_conv_out] = PerformConv(G_rmv_out,Rx_filter_parameter);
%         [Down_sample_out] = DownSampling(Rx_conv_out,IPOINT);
%         [fft_out] = fft_process(noised_out);

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %the output of fft process will be send for multiuser detection and
        %channel estimation jointly. An iterative algorithm is used.
%         [Ch_est_out] = ChannelEstimation(fft_out,CE_gen_out);        
        %est_H_F = ideal_ch;
%         [Crk_ch_out] = CrackChannel(Real_ch_f);
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        %with the channel information obtained in freq. and time
        %direction, respectively.
%         [Crk_pilot_out]=CrackPilot(fft_out);
        %[Cmp_SNR_out] = ComputeSNR(Crk_pilot_out,STBC_out,Crk_ch_out,noise);
        %outage(lp) = Cmp_SNR_out;
        
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        [MRC_out] = MRC(Crk_pilot_out,Crk_ch_out);
        [Demod_out] =  Demodulation(MRC_out);
        [De_i_out] = de_interleaving(Demod_out,IX_IL);
        [Decoding_out] = Decoding_conv(De_i_out);
        %%%%%%%%%%%%%%%
        error(lp) = sum(abs(Demod_out - source_out))/length(source_out);
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%         [mse] = cmpt_ch_mse(ideal_ch_t,est_H_T);
%         est_mse(lp) = mse;
        %%%%%%%%%compute capacity%%%%%%%%%%
        %             [avg_cap_out] = avg_capacity(pilot,est_H_F,R_BS,ch_mse,noise);
        %             cap_lower(lp,iterative) = avg_cap_out;
        % 			[cap_out_upper] = avg_capacity_upper_bound(ideal_ch_f,noise);
        % 			cap_upper(lp,iterative) = cap_out_upper;
    end
  
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %outage_snr(snr+1) = sum(outage)/loop;
   
    bit_err_snr(snr+1) = sum(error)/loop;
    
%     throughput(snr+1) = 1-bit_err_snr(snr+1);
%     est_mse_snr(snr+1) = sum(est_mse)/loop;
%     avg_cap_lower_snr(snr+1,1:IIRV) = sum(cap_lower)/loop;
% 	avg_cap_upper_snr(snr+1,1:IIRV) = sum(cap_upper)/loop;
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end 

snr = 0:2:SNR;

figure(2)
hold on
semilogy(snr,bit_err_snr(snr+1),'-k');
% hold on 
% semilogy(snr,the_bit_err_snr(snr+1),'-b');

snr = 0:2:SNR;


⌨️ 快捷键说明

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