clear all; close all; clc;tic 5%8866% Settings $8868% its_option =2; 966 0:??????,1:??????,2:?????? hoise_option=1; 8% 0:??????,1:?????? =4;NT=2; SNRdBs=[0:2:20];sq05=sqrt(0.5); obe_target =500; BER_target =1e-3; taw_bit_len= 2592-6; nterleaving_num = 72; deinterleaving_num = 72; _frame = 1e8; or i_SNR=1:length(SNRdBs) sig_power=NI;SNRdB=SNRdBs(i_SNR); sigma2=sig_power*10°(-SNRdB/10)*noise_option;sigmal=sqrt(sigma2/2); nobe = 0; Viterbi_init for i_frame=1:1:N_frame I %%88688868896%% ??????866988689686836% switch (bits_option) case (0】, bits=zeros(1,raw_bit_len); case (11, bits=ones(1,raw_bit_len); casef2), bits=randint(1,raw_bit_len); case (2), bits=randi(1,1,raw_bit_len)-1; end 686%6% ?????88%6% encoding_bits= convolution_encoder(bits); 6%%8%% ????? 8686% interleaved=[]; for i=l:interleaving_mum interleaved=[interleavedencoding_bits([i:interleaving_mum:end])];for tx_time-l:648 tx_bits=interleaved(1:8); interleaved(1:8)=[J; ??7 QAM16_symbol=QAM16_mod(tx_bits, 2); ?????69686666366685669 x(1,1) =QAM16_symbol(1);x(2,h)=QAM16_symbol(2); 90969696%????????????? 636585863666666 if rem(tx_time-1,81)==0 H = sq05*(randn(2,2)+j*randn(2,2)); end y =H*x; 66986896%88868% ????? 6688688%%88%% noise = sqrt(sigma2/2)*(randn(2,1)+j*randn(2,1)); if noise_option==1, y = y + noise;end %8%8%88%%8%8% ??????668888688888%% W=inv(H'*H+sigma2*diag (ones(1,2)))*H'; K_tilde =W*y; %%%%88%%8%8% ??????668888%58888%% x_hat = QAM16_slicer(X_tilde, 2); temp_bit=[temp_bit QAM16_denapper(X_hat, 2)]; end %%%8%%%%?????88%8886% deinterleaved=[]; for i=1:deinterleaving_rum deinterleaved=[deinterleaved temp_bit([i:deinterleaving_mum:end])];end %%%86%%%?22220%%%866% received_bit=Viterbi_decode(deinterleaved) 600%%22222 5%0%% for EC_dummy=1:1:raw_bit_len, A bit(BC dumnv) nahesnobe+1:endif nobe>=nobe_target, break; end end if (nobe>=nobe_target) break; end end %8%888888%%%%save BER data & Display 8%88%8888%88%BER(i_SNR)=nobe/((i_frame-1)*raw_bit_len+EC_dummy);fprintf(’t%dt\t%1.4f\n', SNRdB,BER(i_SNR)); if BER(i_SMR)<BER_target, break; end end详细注释这段matlab代码
时间: 2023-09-06 11:09:59 浏览: 453
ClC_SURF_V2.2.zip_V2 _object recognition_surf_物件辨識
这段MATLAB代码实现了一个通信系统的模拟。首先设置了一些参数,包括使用的编码方式、噪声选项、帧数、信噪比等。然后进入一个主循环,循环中对于每一帧数据,进行编码、交织、调制、信道传输、解调、反交织、译码等操作,并计算误比特率(BER)。如果达到预设的误比特率目标或帧数目标,则退出循环。最后输出信噪比和误比特率,并保存数据。注释中对于每个操作都有详细的说明。
阅读全文