




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
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 in tervalMt = 1;% n umber of Tx antennasMr = 1;% n umber of Rx antennassig2 = 1e-3;% no ise varia neeM = 8;% max eon stellati on bit
2、n umberMgap = 10.a(1:(1.7/10):2.7);% gapBtot = 100*Mt;% total # bits per OFDM symbolTransmitIter = 50; % # iterations of symbol transmissions for each channel instanee Channeliter = 100; % # iterations of independent identically distributed channel instances Gapiter = len gth(Mgap);load ENC2.matload
3、 ENC4.matload ENC16.matload ENC64.matload ENC256.matTotEbNo =;Errors =;EbNo =;for lGap = 1:GaplterlGapgap = Mgap(lGap);totalErrors = 0;for lCha n = 1:Cha nn ellter% create cha nnelH h_f=create_cha nn el(Mt, Mr, A, N+GI);% decompose each subcha nnel in the freque ncy doma inU S V = svd_decompose_cha
4、nn el(Mt, Mr, h_f, N);% bitloadi ngbits_alloc,e nergy_alloc = BitLoad(S,Btot,Mt*N,gap,sig2,M);%en ergy_alloc=e nergy_alloc/(mea n(e nergy_alloc);%e nergy_alloc=o nes(1,128);for lTra ns = 1:Tra nsmitlter% bits to tra nsmitx = (ra ndn (1,Btot)>0);% modulatex_mod = modulate(x,bits_alloc,e nergy_allo
5、c, s2,s4,s16,s64,s256);% precode modulated sig nal x_pre = precode(Mt, x_mod, V, N);% ifft, with cyclic prefix for each antennaofdm_symbol =;for i=1:Mtofdm_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);% cha nnely = transpose(cha
6、nnel(sig2, Mt, Mr, ofdm_symbol2, H, N+GI);% fftrec_symbol =;for i=1:Mtrec_symbol = rec_symbol; fft_cp_rx_blk(y(i:Mt:Mt*(N+GI-1)+i),N,GI);endrec_symbol2 = reshape(rec_symbol,1,Mt*N);% shape received sig nalshaped_vals = shape(rec_symbol2, Mr, U, N);% demodulatey_demod = demodulate(shaped_vals, bits_a
7、lloc, en ergy_alloc, S, s2,s4,s16,s64,s256, c2,c4,c16,c64,c256);% comparis ontotalErrors = totalErrors + sum(xor(y_demod,x);endEbNo = EbNo sum(e nergy_alloc)/Btot/sig2;endErrors = Errors totalErrors/Btot/Cha nn elIter/Tra nsmitlterTotEbNo = TotEbNo mea n(EbNo)EbNo =;endsemilogx(TotEbNo, Errors);xlab
8、el('Eb/No');ylabel('BER');title( 'SISO link, adaptive rate and power')save SISO_adaptive2.mat Errors EbNocreate cha nn el.m : Gen erates a Rayleigh fadi ng freque ncy-selectivecha nn el,parametrized by the antenna con figurati on,the OFDM con figurati on,and thepower-delay pr
9、ofile.fun cti onH, H_f=create_cha nn el(Mt, Mr, A, N);% function H, H_f=create_channel(Mt, Mr, A, N);% - -% A - vector containing the power-delay profile (real values)% Mt - n umber of Tx antennas% Mr - n umber of Rx antennas% N - n umber of vector symbols to be sent in a sin gle OFDM symbol Tx% ie:
10、 N MIMO tran smissio ns in one OFDM symbol% This is for Rayleigh freque ncy-selective fading, which assumes complex% Gaussia n matrix eleme nts with in-phase and quadrature comp onentsin depe ndent.% Assume iid matrixchannelelements,and further, independentchanneltaps% defi ne the cha nnel tapsHnt =
11、 1/sqrt(2)*(ra ndn( Mr*le ngth(A),Mt) + j*ra ndn (Mr*le ngth(A),Mt);H_in t2=;for i = 1:le ngth(A)Hnt2 = Hn t2;sqrt(A(i)*H _in t(i-1)*M r+1:i*Mr,:);end%h_f = fft(H_in t2',64);%H = Hn t2'Hnt2 = Hn t2;zeros(N-le ngth(A)*Mr,Mt);H_f = zeros(Mr,Mt*(N-16);for i = 1:Mtfor j = 1:Mrh_f = fft(H _in t2(
12、j:Mr:(N-16-1)*Mr+j,i);for k = 1:(N-16)H_f(j,i+(k-1)*Mt) = h_f(k);endendendH=Hn t2;for i = 1:N-1H=H,zeros(Mr*i,Mt);Hn t2(1:(N-i)*Mr,:);endsvd_decompose_channel.m: Since full channel knowledge is assumed, transmissionis across parallel singular value modes. This functiondecomposes the channel intothes
13、e modes.fun cti on U, S, V = svd_decompose_cha nn el(Mt, Mr, h_f, N);% U S V = svd_decompose_cha nn el(Mt, Mr, h_f, N);% Functiondecomposes the channel at each subcarrier into itsSVD components% Mt - # Tx antennas% Mr - # Rx antennas% h_f - MIMO impulseresponse- Mr rows, Mt*L columns, where L is the
14、 numberof%cha nnel taps% N - # subcarriersU =;S =;V =;for i = 1:NUtmp Stmp Vtmp = svd(h_f(:,(i-1)*Mt+1:i*Mt);U=U Utmp;-V=V Vtmp;S=S Stmp; endS = sum(S,1);en ergyBitLoad.m : Apply the bit-loadingalgorithm to achieve the desired bit andallocati on for the curre nt cha nnel in sta nee.fun cti onbits_al
15、loc,e nergy_alloc=BitLoad(subcha n_gain s,total_bits ,n um_subc,gap ,no ise,M) % Bit Loading Algorithm% % In puts :%subchan_gains : SubCarrier Gains total_bits : Total Number of bits n um_subc : Number of Subcarriers gap : Gap of the system no ise : Noise PowerM : Max Con stellation Size% Outputs:%
16、bits alloc : Bits allocation for each subchannel % power_alloc : Total Power allocati on% % Compute SNR's for each cha nnelSNR = ComputeSNR(subcha n_gains,no ise,gap);% This fun cti on just in itializes the system with a particular bit% allocation and energy allocation using Chow's Algorithm
17、. This is% further efficientize using Campello's Algorithmbits_alloc, en ergy_alloc = chow_algo(SNR ,n um_subc,M);% Form the En ergy In creme nt Table based on the prese nt cha nnel% gains for all the subcha nn els in order to be used by Campello% Algorithmen ergytable = En ergyTablel ni t(SNR,M
18、);% Efficientize the algorithm using the Campello's algorithmbits_alloc,e nergy_alloc=campello_algo(bits_alloc,e nergy_alloc,e nergytable,total_bits, num_subc,M ); _ _ _ - -ComputeSNR.m : Give n the subcarrier gains, this simple fun ctio n gen erates the SNR values of each cha nn el (each sin gu
19、lar value on each tone is a separate cha nn el).fun cti onSNR = ComputeSNR(subcar_ga ins,no ise,gap)SNR = abs(subcar_ga in s.A2)./( noise*gap);chow_algo.m : Apply Chow's algorithm to gen erate a particular bit anden ergyallocati on.% Chow's Algorithm% This is based on the paper by Chow et al
20、 titled% A Practical Discrete Multit one Tran sceiver Loadi ng Algorithm% for Data Tran smissi on over Spectrally Shaped Chann els .I EEE Tra ns% on Communications. Vol. 43, No 2/3/4, pp. 773-775, Feb/Mar/Apr 1995fun cti onbits_alloc, en ergy_alloc = chow_algo(SNR, num_subc,M) for i = 1:n um_subc% A
21、ssuming each of the subchannelshas a flat fading, we get initial estimate% of the bits for each subcha nneltempbits = log2(1 + abs(SNR(i);% bits per two dime nsion.rou ndtempbits = roun d(tempbits);% round the bitsif (rou ndtempbits > 8)% Limit them betwee n 2 and 15rou ndtempbits = 8;endif (mod(
22、rou ndtempbits,2)= 1 & rou ndtempbits = 1) roundtempbits = roundtempbits -1;end% Calculate the En ergyrequired% Update the BitSubChanif rou ndtempbits> 0for the subcha nnelenergy_alloc(i) = (2Aroundtempbits-1)/SNR(i);elseen ergy_alloc(i) = 0;endbits_alloc(i) = roun dtempbits;end % end of fun
23、cti onEn ergyTable In it.m: Give n the SNR values, form a table of en ergy in creme nts for eachcha nn el.fun cti onen ergytable = En ergyTablel ni t(SNR,M);% In puts:subcar_ga ins : Subcarrier Gains%M : max Con stellati on Size % Gap : Gap of the system % Noise : Noise Power % Outputs: % en ergytab
24、le : En ergytable % Based on the Subcarrier Gai ns, we calculate the en ergy % in creme nt required by each subcarrier for tran smitt ing % 1,2 ,4 ,6,8 bits.% En ergy = 2A(i-1)/subcar_ga ins;%subcar_ga ins = (subcar_ga in s.A2)/(Gap*Noise);en ergytable = abs(1./SNR)'*(2.A(i:M+1-1);% In crease th
25、e en ergy value for con stellati on size of more tha n M to% a very high value so that it is not assig ned.en ergytable(:,M+1) = lnf*on es(size(e nergytable(:,M+1);for i = 3:2:Men ergytable(:,i) = (en ergytable(:,i) +en ergytable(:,i+1)/2;en ergytable(:,i+1) = en ergytable(:,i);end%en ergytable = on
26、 es(1,size(e nergytable,1)' en ergytable;bit anden ergycampello algo.m : Apply Campello's algorithm to con vergeto the optimalen ergy allocati on for the give n cha nnel con diti ons.% campello_algo.m% Thisfunctionis used by Campello's algorithm to allocate bits andfor% each subcha nnel
27、optimally.fun cti on bits_alloc, en ergy_alloc=campello_algo(bits_alloc,e nergy_alloc,e nergytable,total_bits, num_subc,M) _ _ _ - -bt = sum(bits_alloc);% We can't tran smit more tha n M*(Number of subcha nn el) bitsif total_bits > M*n um_subctotal_bits = M*n um_subc;endwhile (bt = total_bits
28、)if (bt > total_bits)max_val = 0;max_i nd = ceil(ra nd(1)* num_subc);for i = 1:n um_subcif bits_alloc(i) = 0temp = en ergytable(i,bits_alloc(i);elsetemp = 0;endif (temp > max_val)max_val = temp;max_i nd = i;endendif (bits_alloc(max_i nd) > 0) bits_alloc(max_i nd) = bits_alloc(max_i nd) -1;
29、en ergy_alloc(max_i nd) = en ergy_alloc(max_i nd) - max_val; bt = bt-1;endelsemin_val = Inf;min_ind = ceil(ra nd(1)* num_subc);for i = 1:n um_subcif bits_alloc(i) =0 & bits_alloc(i) <9temp = en ergytable(i,bits_alloc(i) + 1);elsetemp = Inf;endif (temp < min_val)min_val = temp;min_i nd = i;
30、endendif (bits_alloc(min_i nd) < 8)bits_alloc(min_i nd) = bits_alloc(min_i nd) +1;if (min_val=i nf)min_val = en ergytable(min_i nd,bits_alloc(min_i nd);enden ergy_alloc(min_i nd) = en ergy_alloc(min_i nd) +min_val;bt = bt+1;endendendfor i = 1:le ngth(bits_alloc)if (mod(bits_alloc(i),2) = 1 & bits_alloc(i) =1)b
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司沙漠活動方案
- 公司聚會端午節(jié)活動方案
- 公司茶花會策劃方案
- 公司荔枝活動方案
- 公司滑雪團(tuán)建活動方案
- 公司流量策劃方案
- 公司環(huán)保團(tuán)建活動方案
- 公司春季海邊活動方案
- 公司聚會場地策劃方案
- 公司春節(jié)放假策劃方案
- 小學(xué)生匯報講課件
- 2025浙江嘉興市海寧市嘉睿人力招聘5人筆試參考題庫附帶答案詳解析版
- 2025年安徽蚌埠市龍子湖區(qū)東方人力資源有限公司招聘筆試參考題庫含答案解析
- 2025至2030中國云計算行業(yè)產(chǎn)業(yè)運(yùn)行態(tài)勢及投資規(guī)劃深度研究報告
- 黨課課件含講稿:《關(guān)于加強(qiáng)黨的作風(fēng)建設(shè)論述摘編》輔導(dǎo)報告
- GB/T 19023-2025質(zhì)量管理體系成文信息指南
- 2025中考?xì)v史高頻點(diǎn)速記大全
- 2025年特種設(shè)備作業(yè)人員氣瓶充裝P證考試題庫
- 《智能駕駛輔助系統(tǒng)ADAS》課件
- 2024年自然資源部所屬單位招聘筆試真題
- 江西吉安市吉水縣吉瑞招商運(yùn)營有限公司招聘筆試題庫2025
評論
0/150
提交評論