




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、OFDM.m: OFDM Simulator (outer function)clear all; A = 1 1/exp(1) 1/exp(2); % power delay profileN = 64; % number of symbols in a single OFDM symbolGI = 16; % guard intervalMt = 1; % number of Tx antennasMr = 1; % number of Rx antennassig2 = 1e-3; % noise varianceM = 8; % max constellation bit number
2、Mgap = 10.(1:(1.7/10):2.7); % gapBtot = 100*Mt; % total # bits per OFDM symbolTransmitIter = 50; % # iterations of symbol transmissions for each channel instanceChannelIter = 100; % # iterations of independent identically distributed channel instancesGapIter = length(Mgap); load ENC2.matload ENC4.ma
3、tload ENC16.matload ENC64.matload ENC256.mat TotEbNo = ;Errors =;EbNo = ;for lGap = 1:GapIterlGapgap = Mgap(lGap);totalErrors = 0;for lChan = 1:ChannelIter % create channelH h_f=create_channel(Mt, Mr, A, N+GI); % decompose each subchannel in the frequency domainU S V = svd_decompose_channel(Mt, Mr,
4、h_f, N); % bitloadingbits_alloc,energy_alloc = BitLoad(S,Btot,Mt*N,gap,sig2,M);%energy_alloc=energy_alloc/(mean(energy_alloc);%energy_alloc=ones(1,128); for lTrans = 1:TransmitIter % bits to transmitx = (randn(1,Btot)>0); % modulatex_mod = modulate(x,bits_alloc,energy_alloc, s2,s4,s16,s64,s256);
5、% precode modulated signalx_pre = precode(Mt, x_mod, V, N); % ifft, with cyclic prefix for each antennaofdm_symbol =;for i=1:Mt ofdm_symbol = ofdm_symbol; ifft_cp_tx_blk(x_pre(i:Mt:Mt*(N-1)+i),N,GI);endofdm_symbol2 = reshape(ofdm_symbol,Mt*(N+GI),1); % channely = transpose(channel(sig2, Mt, Mr, ofdm
6、_symbol2, H, N+GI); % fftrec_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 signalshaped_vals = shape(rec_symbol2, Mr, U, N); % demodulatey_demod = demodulate(shaped_vals, bits_alloc, energy_alloc,
7、 S, s2,s4,s16,s64,s256, c2,c4,c16,c64,c256); % comparisontotalErrors = totalErrors + sum(xor(y_demod,x);endEbNo = EbNo sum(energy_alloc)/Btot/sig2;end Errors = Errors totalErrors/Btot/ChannelIter/TransmitIterTotEbNo = TotEbNo mean(EbNo)EbNo = ;end semilogx(TotEbNo, Errors);xlabel('Eb/No');yl
8、abel('BER');title('SISO link, adaptive rate and power') save SISO_adaptive2.mat Errors EbNocreate_channel.m: Generates a Rayleigh fading frequency-selective channel, parametrized by the antenna configuration, the OFDM configuration, and the power-delay profile.function H, H_f=create_
9、channel(Mt, Mr, A, N);% function H, H_f=create_channel(Mt, Mr, A, N);% A - vector containing the power-delay profile (real values)% Mt - number of Tx antennas% Mr - number of Rx antennas% N - number of vector symbols to be sent in a single OFDM symbol Tx% ie: N MIMO transmissions in one OFDM symbol
10、% This is for Rayleigh frequency-selective fading, which assumes complex% Gaussian matrix elements with in-phase and quadrature components independent.% Assume iid matrix channel elements, and further, independent channel taps % define the channel tapsH_int = 1/sqrt(2)*(randn(Mr*length(A),Mt) + j*ra
11、ndn(Mr*length(A),Mt); H_int2=;for i = 1:length(A) H_int2 = H_int2;sqrt(A(i)*H_int(i-1)*Mr+1:i*Mr,:);end %h_f = fft(H_int2',64); %H = H_int2' H_int2 = H_int2;zeros(N-length(A)*Mr,Mt); H_f = zeros(Mr,Mt*(N-16);for i = 1:Mt for j = 1:Mr h_f = fft(H_int2(j:Mr:(N-16-1)*Mr+j,i); for k = 1:(N-16) H
12、_f(j,i+(k-1)*Mt) = h_f(k); end endend H=H_int2;for i = 1:N-1 H=H,zeros(Mr*i,Mt);H_int2(1:(N-i)*Mr,:);endsvd_decompose_channel.m: Since full channel knowledge is assumed, transmission is across parallel singular value modes. This function decomposes the channel into these modes.function U, S, V = svd
13、_decompose_channel(Mt, Mr, h_f, N);% U S V = svd_decompose_channel(Mt, Mr, h_f, N);% Function decomposes the channel at each subcarrier into its SVD components% Mt - # Tx antennas% Mr - # Rx antennas% h_f - MIMO impulse response - Mr rows, Mt*L columns, where L is the number of% channel taps% N - #
14、subcarriers U = ;S = ;V = ;for i = 1:N Utmp Stmp Vtmp = svd(h_f(:,(i-1)*Mt+1:i*Mt); U=U Utmp; V=V Vtmp; S=S Stmp;end S = sum(S,1);BitLoad.m: Apply the bit-loading algorithm to achieve the desired bit and energy allocation for the current channel instance.function bits_alloc,energy_alloc = BitLoad(su
15、bchan_gains,total_bits,num_subc,gap,noise,M) % Bit Loading Algorithm% -% Inputs :% subchan_gains : SubCarrier Gains% total_bits : Total Number of bits % num_subc : Number of Subcarriers% gap : Gap of the system% noise : Noise Power% M : Max Constellation Size% Outputs:% bits_alloc : Bits allocation
16、for each subchannel% power_alloc : Total Power allocation % - % Compute SNR's for each channelSNR = ComputeSNR(subchan_gains,noise,gap); % This function just initializes the system with a particular bit % allocation and energy allocation using Chow's Algorithm. This is % further efficientize
17、 using Campello's Algorithm bits_alloc, energy_alloc = chow_algo(SNR,num_subc,M); % Form the Energy Increment Table based on the present channel% gains for all the subchannels in order to be used by Campello% Algorithm energytable = EnergyTableInit(SNR,M); % Efficientize the algorithm using the
18、Campello's algorithmbits_alloc,energy_alloc = campello_algo(bits_alloc,energy_alloc,energytable,total_bits,num_subc,M); ComputeSNR.m: Given the subcarrier gains, this simple function generates the SNR values of each channel (each singular value on each tone is a separate channel).function SNR =
19、ComputeSNR(subcar_gains,noise,gap) SNR = abs(subcar_gains.2)./(noise*gap);chow_algo.m: Apply Chow's algorithm to generate a particular bit and energy allocation.% Chow's Algorithm% -% This is based on the paper by Chow et al titled% A Practical Discrete Multitone Transceiver Loading Algorith
20、m % for Data Transmission over Spectrally Shaped Channels.IEEE Trans% on Communications. Vol. 43, No 2/3/4, pp. 773-775, Feb/Mar/Apr 1995 function bits_alloc, energy_alloc = chow_algo(SNR,num_subc,M) for i = 1:num_subc% Assuming each of the subchannels has a flat fading, we get initial estimate% of
21、the bits for each subchannel tempbits = log2(1 + abs(SNR(i); % bits per two dimension. roundtempbits = round(tempbits); % round the bits if (roundtempbits > 8) % Limit them between 2 and 15 roundtempbits = 8; end if (mod(roundtempbits,2)= 1 & roundtempbits = 1) roundtempbits = roundtempbits -
22、1; end if roundtempbits > 0 % Calculate the Energy required for the subchannel energy_alloc(i) = (2roundtempbits-1)/SNR(i) ; else energy_alloc(i) = 0; end bits_alloc(i) = roundtempbits; % Update the BitSubChan end % end of functionEnergyTableInit.m: Given the SNR values, form a table of energy in
23、crements for each channel.function energytable = EnergyTableInit(SNR,M); % Inputs:% subcar_gains : Subcarrier Gains% M : max Constellation Size% Gap : Gap of the system% Noise : Noise Power% Outputs:% energytable : Energytable % Based on the Subcarrier Gains, we calculate the energy% increment requi
24、red by each subcarrier for transmitting% 1,2 ,4 ,6,8 bits.% Energy = 2(i-1)/subcar_gains;% - %subcar_gains = (subcar_gains.2)/(Gap*Noise); energytable = abs(1./SNR)'*(2.(1:M+1-1); % Increase the energy value for constellation size of more than M to % a very high value so that it is not assigned.
25、 energytable(:,M+1) = Inf*ones(size(energytable(:,M+1); for i = 3:2:M energytable(:,i) = (energytable(:,i) +energytable(:,i+1)/2; energytable(:,i+1) = energytable(:,i);end %energytable = ones(1,size(energytable,1)' energytable;campello_algo.m: Apply Campello's algorithm to converge to the op
26、timal bit and energy allocation for the given channel conditions.% campello_algo.m% -% This function is used by Campello's algorithm to allocate bits and energy for % each subchannel optimally. function bits_alloc, energy_alloc = campello_algo(bits_alloc,energy_alloc,energytable,total_bits,num_s
27、ubc,M) bt = sum(bits_alloc); % We can't transmit more than M*(Number of subchannel) bitsif total_bits > M*num_subc total_bits = M*num_subc;end while (bt = total_bits) if (bt > total_bits) max_val = 0; max_ind = ceil(rand(1)*num_subc); for i = 1:num_subc if bits_alloc(i) = 0 temp = energyta
28、ble(i,bits_alloc(i) ; else temp = 0; end if (temp > max_val) max_val = temp; max_ind = i; end end if (bits_alloc(max_ind) > 0) bits_alloc(max_ind) = bits_alloc(max_ind) -1; energy_alloc(max_ind) = energy_alloc(max_ind) - max_val; bt = bt-1; end else min_val = Inf; min_ind = ceil(rand(1)*num_su
29、bc); for i = 1:num_subc if bits_alloc(i) =0 & bits_alloc(i) <9 temp = energytable(i,bits_alloc(i) + 1); else temp = Inf; end if (temp < min_val) min_val = temp; min_ind = i; end end if (bits_alloc(min_ind) < 8) bits_alloc(min_ind) = bits_alloc(min_ind) +1; if (min_val=inf) min_val = energytable(min_ind,bits_alloc(min_ind); end energy_alloc(min_ind) = energy_alloc(min_ind) +min_val; bt = bt+1; end end end for i = 1:length(bits_alloc) if (mod(bits_alloc(i),2) = 1 & bits_alloc(i) =1) bits_alloc,energy_
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 防災(zāi)減災(zāi)施工檢測(cè)試驗(yàn)計(jì)劃
- 六年級(jí)英語聽力強(qiáng)化計(jì)劃
- 北師大版九年級(jí)數(shù)學(xué)個(gè)別輔導(dǎo)計(jì)劃
- 總烴油蒸氣中毒查房
- 2025小學(xué)二年級(jí)語文暑期教學(xué)計(jì)劃
- 教師2025年個(gè)人師德團(tuán)隊(duì)提升計(jì)劃
- 物理力學(xué)概念深化與實(shí)驗(yàn):力學(xué)基礎(chǔ)課程教案
- 《力學(xué)中動(dòng)量定理的應(yīng)用:高中物理進(jìn)階教案》
- 校企合作發(fā)展戰(zhàn)略與工作計(jì)劃
- 幼兒園教職工教學(xué)創(chuàng)新培訓(xùn)計(jì)劃
- 山東省濱州市名校2025屆物理八下期末綜合測(cè)試模擬試題含解析
- 醫(yī)療領(lǐng)域AI人才薪酬市場(chǎng)現(xiàn)狀及趨勢(shì)
- 金融行業(yè)信息安全培訓(xùn)
- 醫(yī)療廢物管理
- 2025+NCCN非小細(xì)胞肺癌診療指南解讀
- ECMO治療暴發(fā)性心肌炎
- 山東詠坤新材料科技有限公司年產(chǎn)4000噸鋰鈉電池負(fù)極材料生產(chǎn)項(xiàng)目報(bào)告書
- 中老年人健康教育宣講
- 社會(huì)單位消防安全評(píng)估導(dǎo)則
- IT云圖2025:中國(guó)算力區(qū)域競(jìng)爭(zhēng)力研究
- 四川省成都市成華區(qū)2023-2024學(xué)年高一下學(xué)期期末考試數(shù)學(xué)試題(解析版)
評(píng)論
0/150
提交評(píng)論