ofdm-qpsk-mycreatechannel.rar

  • brtmoon
    了解作者
  • matlab
    开发工具
  • 50KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 21
    下载次数
  • 2010-05-06 22:16
    上传日期
ofdm系统设计,采用qpsk调制,可以轻松改变信道条件,比较研究,是非常方便的工具,我用了很多次了,很不错哦!!!
ofdm-qpsk-mycreatechannel.rar
  • ofdm-qpsk-mycreatechannel
  • 384bpsBER.fig
    8.8KB
  • ComputeSNR.m
    134B
  • bpsBER1-7.fig
    29.7KB
  • ENC2.mat
    256B
  • curveofsnrindBtotebno.m
    647B
  • 192-3bpsBER.fig
    8.7KB
  • svd_decompose_channel.m
    565B
  • channel.m
    875B
  • ENC256.mat
    6.2KB
  • ifft_cp_tx_blk+.m
    1003B
  • 256-4bpsBER.fig
    9KB
  • shape.m
    594B
  • oversamp2.m
    507B
  • BitLoad.m
    1.5KB
  • qpskdemod.m
    723B
  • ENC16.mat
    568B
  • channel1.m
    167B
  • compoversamp.m
    684B
  • SISO_adaptive2.mat
    336B
  • ENC64.mat
    1.6KB
  • demodulate.m
    1.4KB
  • ResolvetheLastBit.m
    1.2KB
  • fft_cp_rx_blk.m
    1022B
  • 128bpsBER.fig
    8.8KB
  • ofdm.asv
    7.8KB
  • hrollfcoef.m
    1.6KB
  • ENC4.mat
    320B
  • mycreatechannel.m
    1KB
  • precode.m
    740B
  • Qfunct.m
    98B
  • qpsk1.m
    4.2KB
  • chow_algo.m
    1.1KB
  • qpsk1.asv
    4.2KB
  • comb.m
    658B
  • EnergyTableInit.m
    1.3KB
  • ifft_cp_tx_blk.m
    1003B
  • 448-7bpsBER.fig
    9KB
  • 384-6bpsBER.fig
    9KB
  • mycreatechannel.asv
    953B
  • 64-1bpsBER.fig
    9.8KB
  • compconv.m
    562B
  • 320-5bpsBER.fig
    9KB
  • bpsBER17.fig
    62KB
  • campello_algo.m
    2.2KB
  • oversamp.m
    497B
  • 128-2bpsBER.fig
    29.7KB
  • qpskmod.m
    913B
  • ofdm.m
    7.8KB
  • modulate.m
    1.2KB
内容介绍
clear all; A = [1 1/exp(1) 1/exp(2)]; % power delay profile N = 64; % number of symbols in a single OFDM symbol载波数 GI = 16; % guard interval Mt = 1; % number of Tx antennas发射天线 Mr = 1; % number of Rx antennas接收天线 sig2 = 1e-3; % noise variance噪声方差 M = 8; % max constellation bit number最大星座图比特数 Mgap = 10.^(1:(1.7/10):2.7); % gap Btot = 64*2*Mt; % total # bits per OFDM symbol TransmitIter = 1; % # iterations of symbol transmissions for each channel instance50输入数据流循环次数 ChannelIter = 2; % # iterations of independent identically distributed channel instances100 GapIter = length(Mgap); load ENC2.mat load ENC4.mat load ENC16.mat load ENC64.mat load ENC256.mat TotEbNo = []; Errors =[]; EbNo = []; for lGap = 1:GapIter lGap gap = Mgap(lGap)% 系统间隔lGap =1,gap =10;lGap = 2,gap =14.7911;lGap = 3,gap = 21.8776;lGap = 4,gap = 32.3594 lGap =5,gap =47.8630;lGap=6,gap = 70.7946;lGap = 7,gap =104.7129;;lGap =8,gap =154.8817;lGap = 9,gap =229.0868;lGap =10,gap =338.8442; lGap =11,gap =501.1872 totalErrors = 0; for lChan = 1:ChannelIter % create channel %[H h_f]=create_channel(Mt, Mr, A, N+GI); [H h_f]=mycreatechannel(Mt, Mr, A, N+GI); magH=fft(H,64); magx=abs(magH(1:1:35));%信道频域特性 k=[0:1:34]; %figure(3) %plot(k,magx,'k'); % decompose each subchannel in the frequency domain 分解子信道 [U S V] = svd_decompose_channel(Mt, Mr, h_f, N); % bitloading [bits_alloc,energy_alloc] = BitLoad(S,Btot,Mt*N,gap,sig2,M);% S:信道增益 计算信道可分配的比特数和功率数 %energy_alloc=energy_alloc/(mean(energy_alloc)); %energy_alloc=ones(1,128); for lTrans = 1:TransmitIter % bits to transmit x = (randn(1,Btot)>0); % modulate x_mod = modulate(x,bits_alloc,energy_alloc, s2,s4,s16,s64,s256); % precode modulated signal x_pre = precode(Mt, x_mod, V, N); % ifft, with cyclic prefix for each antenna ofdm_symbol =[]; for i=1:Mt ofdm_symbol = [ofdm_symbol; ifft_cp_tx_blk(x_pre(i:Mt:Mt*(N-1)+i),N,GI)]; end ofdm_symbol2 = reshape(ofdm_symbol,Mt*(N+GI),1); % channel y = transpose(channel(sig2, Mt, Mr, ofdm_symbol2, H, N+GI)); % fft rec_symbol =[]; for i=1:Mt rec_symbol = [rec_symbol; fft_cp_rx_blk(y(i:Mt:Mt*(N+GI-1)+i),N,GI)]; end rec_symbol2 = reshape(rec_symbol,1,Mt*N); % shape received signal shaped_vals = shape(rec_symbol2, Mr, U, N); % demodulate y_demod = demodulate(shaped_vals, bits_alloc, energy_alloc, S, s2,s4,s16,s64,s256, c2,c4,c16,c64,c256); % comparison totalErrors = totalErrors + sum(xor(y_demod,x)); end EbNo = [EbNo sum(energy_alloc)/Btot/sig2]; end Errors = [Errors totalErrors/Btot/ChannelIter/TransmitIter] TotEbNo = [TotEbNo mean(EbNo)] TotEbNoindB=10*log10(TotEbNo) EbNo = []; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % the channel-print of the time domain and frequency %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %figure(2) %bit allocation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %subplot(3,1,1); %plot(k,magx); %subplot(3,1,2); %stem(bits_alloc,'.','k'); %subplot(3,1,3); %stem(energy_alloc,'.','k'); figure(3) plot(k,magx,'k'); figure(5) subplot(2,1,1) plot(k,magx,'k'); title( 'ofdm-mycreatchannel') subplot(2,1,2) semilogy(TotEbNoindB, Errors,':p');axis([0,35 ,0.0001, 1]);grid xlabel('E/N'); ylabel('BER'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 %%%%%%%%%%the error bit is varified with the ebno %%%%%%%%%%%%%%%%%%%%%%%%%%%% %adaptive ofdm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%qpsk %A = [1 1/exp(1) 1/exp(2)]; % power delay profile N = 1; % number of symbols in a single OFDM symbol载波数 %GI = 16; % guard interval Mt = 1; % number of Tx antennas发射天线 Mr = 1; % number of Rx antennas接收天线 sig2 = 1e-3; % noise variance噪声方差 %M = 8; % max constellation bit number最大星座图比特数 %Mgap = 10.^(1:(1.7/10):2.7); % gap %Btot = 64*2*Mt; % total # bits per OFDM symbol TransmitIter = 1; % # iterations of symbol transmissions for each channel instance50输入数据流循环次数 ChannelIter = 1; % # iterations of independent identically distributed channel instances100 %GapIter = length(Mgap); %ebn0indB=[870.87,661.14,376.06,159.17,101.35,192.31,338.53,431.8,418.76,324.89,221.2,163.74,153.79,147.87,106.75,41.907,19.161,112.24,339.06,629.72,855.18,902.36,746.41,470.28,216.4,101.41,150.15,290.91,411.54,434.81,361.06,252.46,176.43,154.04,152.54,124.98,62.875,16.939,65.506,251.15,533.2,795.51,910.31,817.79,567.21,289.89,120.52,118.57,240.73,379.76,439.52,393.32,287.78,195.58,156.74,153.96,138.83,85.372,25.531,34.75,174.64,434.61,718.85,894.25]; % Eb/N0 %ebn0indB=[7.6606,9.3606,11.061,12.761,14.461,16.161,17.861,19.561,21.261,22.961,24.663]; ebn0indB=[16.491,24.392,36.078,53.363,78.93,116.75,172.68,255.41,377.78,558.78,826.5] %ebn0indB=0:0.8:35; for i=1:length(ebn0indB); %ebn0=3; % Eb/N0 sr=256000.0; % Symbol rate ml=2; % ml:Number of modulation levels (BPSK:ml=1, QPSK:ml=2, 16QAM:ml=4,64QAM=16) br=sr .* ml; % Bit rate nd = 1000; % Number of symbols that simulates (仿真)in each loop %IPOINT=8; % Number of oversamples;Number of samples in one symbol %************************* Filter initialization *************************** %irfn=21; % Number of taps;Number of symbols to use filtering %alfs=0.5; % Rolloff factor %[xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); %Transmitter filter coefficients (系数) %[xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0); %Receiver filter coefficients %******************** START CALCULATION ************************************* %nloop=10; % Number of simulation loops noe = 0; % Number of error data nod = 0; % Number of transmitted data %for iii=1:nloop % create channel %[H h_f]=create_channel(Mt, Mr, A, N+GI); [H h_f]=mycreatechannel(Mt, Mr, 1, N); magH=fft(H,64); magx=abs(magH(1:1:35));%信道频域特性 k=[0:1:34]; %figure(3) %subplot(2,1,2); %plot(k,magx,'k'); %*************************** Data generation ******************************** data1=rand(1,nd*ml)>0;%产生0和1随机数,1行2000列 %*************************** QPSK Modulation ******************************** [ich,qch]=qpskmod(data1,1,nd,ml); %[ich1,qch1]= compoversamp(ich,qch,length(ich),IPOINT); %[ich2,qch2]= compconv(ich1,qch1,xh); %**************************** Attenuation Calculation *********************** %spow=sum(ich2.*ich2+qch2.*qch2)/nd; %attn=0.5*spow*sr/br*10.^(-ebn0indB(i)/10); %attn=sqrt(attn); % sqrt: built in function %********************* Add White Gaussian Noise (AWGN) ********************** %[ich3,qch3]= comb(ich2,qch2,attn);% add white gaussian noise %[ich4,qch4]= compconv(ich3,qch3,xh2); %syncpoint=irfn*IPOINT+1; %ich5=ich4(syncpoint:IPOINT:length(ich4)); %qch5=qch4(syncpoint:IPOINT:length(qch4)); % channel iy = channel(sig2, Mt, Mr, ich,H, N); qy =channel(sig2, Mt, Mr, qch, H, N); %**************************** QPSK Demodulation ***************************** % [demodata]=qpskdemod(ich5,qch5,1,nd,ml); [demodata]=qpskdemod(iy,qy,1,nd,ml); %************************** Bit Error Rate (BER) **************************** noe2=sum(abs(data1-demodata)); nod2=length(data1); noe=noe+noe2; nod=nod+nod2; %end % for iii=1:nloop %********************** Output result *************************** %SNR = abs((subcar_gains.^2)./(noise*gap)); ber = noe/nod; s1(i)=ebn0indB(i); s2(i)=ber; %s3(i)=noe %s4(i)=nod end;%for enb0 figure(4) subplot(2,1,1) plot(k,magx,'k'); title('qpsk-mycreatchannel') subplot(2,1,2) semilogy(s1,s2,'r'); semilogy(s1,s2,':p','Color','r');axis([0,35,0.0001, 2]);grid xlabel('E/N'); ylabel('BER'); figure(6) subplot(2,1,1) plot(k,magx,'k'); subplot(2,1,2) semilogy(s1,s2,':p','Color','r','LineWidth',2); hold on semilogy(TotEbNoindB, Errors,':p','LineWidth',2); axis([0,35,0.0001, 2]);grid xlabel('E/N'); ylabel('BER'); hold of
评论
    相关推荐