clear;clc;SNR=10; %信噪比fl=128; %設(shè)置FFT長(zhǎng)度Ns=6; %設(shè)置一個(gè)禎結(jié)構(gòu)中OFDM信號(hào)的個(gè)數(shù)para=128; %設(shè)置并行傳輸?shù)淖虞d波個(gè)數(shù)sr=250000; %符號(hào)速率br=sr.*2; %每個(gè)子載波的比特率gl=32; %保護(hù)時(shí)隙的長(zhǎng)度nloop=1; %仿真循環(huán)次數(shù)noe=0; %誤碼數(shù)nod=0; %傳輸?shù)臄?shù)據(jù)數(shù)量eop=0; %誤組數(shù)nop=0; %傳輸?shù)姆纸M數(shù)for iii=1:nloop end%-------------產(chǎn)生數(shù)據(jù)------------Signal=round(rand(1,para*Ns*2))>0.5; %產(chǎn)生0,1隨即序列,符號(hào)數(shù)為para*Ns*2,Signal實(shí)際得到的%是右邊邏輯表達(dá)式的結(jié)果,rand產(chǎn)生的值如果大于0.5,則Signal為1,如果小于0.5,則Signal為0%------------串并轉(zhuǎn)換---------for i=1:flfor j=1:Ns*2ParaBitSig(i,j)=Signal(i*j);end%------------QPSK調(diào)制--------for j=1:Nsich(:,j)=ParaBitSig(:,2*j-1);qch(:,j)=ParaBitSig(:,2*j);endkmod=1./sqrt(2);ich0=ich.*2-1;qch0=qch.*2-1;ich1=ich0.*kmod;qch1=qch0.*kmod;qpsk_x=ich1+qch1.*sqrt(-1); %頻域數(shù)據(jù)變時(shí)域%---------------IFFT------------fy=ifft(qpsk_x);ich2=real(fy);qch2=imag(fy);%--------------插入保護(hù)間隔------------ich3=[ich2(para-gl+1:para,:);ich2];qch3=[qch2(para-gl +1:para,:);qch2];%--------------計(jì)算衰減--------------spow=sum(ich3.^2+qch3.^2)/Ns./para;attn=0.5*spow*sr/br*10.^(-SNR/10);attn=sqrt(attn);%并串變換ich4=reshape(ich3,1,(fl+gl)*Ns);qch4=reshape(qch3,1,(fl+gl)*Ns);%形成復(fù)數(shù)發(fā)射數(shù)據(jù)TrData=ich4+qch4.*sqrt(-1);%接收機(jī)%----------加入高斯白噪聲-----------ReData=awgn(TrData,SNR,'measured');idata=real(ReData);qdata=imag(ReData);idata1=reshape(idata,fl+gl,Ns);qdata1=reshape(qdata,fl+gl,Ns);idata2=idata1(gl+1:gl+fl,:);qdata2=qdata1(gl+1:gl+fl,:);Rex=idata2+qdata2.*sqrt(-1);ry=fft(Rex);ReIChan=real(ry);ReQChan=imag(ry);ReIchan1=ReIChan/kmod;ReQchan1=ReQChan/kmod;ReIChan0=(ReIChan1+1)/2;ReQChan0=(ReQchan1+1)/2;for j=1:NsRepara(:,2*j-1)=ReIChan0(:,j);Repara(:,2*j)=ReQChan(:,j);end ReSig=reshape(RePara,1,para*Ns*2);ReSig=ReSig>0.5;------
1 回答

料青山看我應(yīng)如是
TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊
你這里面錯(cuò)誤好多,應(yīng)該根據(jù)程序的提示好好檢查一下。
clear; clc; SNR= 10 ; %信噪比 fl= 128 ; %設(shè)置FFT長(zhǎng)度 Ns= 6 ; %設(shè)置一個(gè)禎結(jié)構(gòu)中OFDM信號(hào)的個(gè)數(shù) para= 128 ; %設(shè)置并行傳輸?shù)淖虞d波個(gè)數(shù) sr= 250000 ; %符號(hào)速率 br=sr.* 2 ; %每個(gè)子載波的比特率 gl= 32 ; %保護(hù)時(shí)隙的長(zhǎng)度 nloop= 1 ; %仿真循環(huán)次數(shù) noe= 0 ; %誤碼數(shù) nod= 0 ; %傳輸?shù)臄?shù)據(jù)數(shù)量 eop= 0 ; %誤組數(shù) nop= 0 ; %傳輸?shù)姆纸M數(shù) for iii= 1 :nloop end %-------------產(chǎn)生數(shù)據(jù)------------ Signal=round(rand( 1 ,para*Ns* 2 ))> 0.5 ; %產(chǎn)生 0 , 1 隨即序列,符號(hào)數(shù)為para*Ns* 2 ,Signal實(shí)際得到的%是右邊邏輯表達(dá)式的結(jié)果,rand產(chǎn)生的值如果大于 0.5 ,則Signal為 1 ,如果小于 0.5 ,則Signal為 0 %------------串并轉(zhuǎn)換--------- for i= 1 :fl for j= 1 :Ns* 2 ParaBitSig(i,j)=Signal(i*j); end end %------------QPSK調(diào)制-------- for j= 1 :Ns ich(:,j)=ParaBitSig(:, 2 *j- 1 ); qch(:,j)=ParaBitSig(:, 2 *j); end kmod= 1 ./sqrt( 2 ); ich0=ich.* 2 - 1 ; qch0=qch.* 2 - 1 ; ich1=ich0.*kmod; qch1=qch0.*kmod; qpsk_x=ich1+qch1.*sqrt(- 1 ); %頻域數(shù)據(jù)變時(shí)域 %---------------IFFT------------ fy=ifft(qpsk_x); ich2=real(fy); qch2=imag(fy); %--------------插入保護(hù)間隔------------ ich3=[ich2(para-gl+ 1 :para,:);ich2]; qch3=[qch2(para-gl + 1 :para,:);qch2]; %--------------計(jì)算衰減-------------- spow=sum(ich3.^ 2 +qch3.^ 2 )/Ns./para; attn= 0.5 *spow*sr/br* 10 .^(-SNR/ 10 ); attn=sqrt(attn); %并串變換 ich4=reshape(ich3, 1 ,(fl+gl)*Ns); qch4=reshape(qch3, 1 ,(fl+gl)*Ns); %形成復(fù)數(shù)發(fā)射數(shù)據(jù) TrData=ich4+qch4.*sqrt(- 1 ); %接收機(jī) %----------加入高斯白噪聲----------- ReData=awgn(TrData,SNR, 'measured' ); idata=real(ReData); qdata=imag(ReData); idata1=reshape(idata,fl+gl,Ns); qdata1=reshape(qdata,fl+gl,Ns); idata2=idata1(gl+ 1 :gl+fl,:); qdata2=qdata1(gl+ 1 :gl+fl,:); Rex=idata2+qdata2.*sqrt(- 1 ); ry=fft(Rex); ReIChan=real(ry); ReQChan=imag(ry); ReIchan1=ReIChan/kmod; ReQchan1=ReQChan/kmod; ReIChan0=(ReIchan1+ 1 )/ 2 ; ReQChan0=(ReQchan1+ 1 )/ 2 ; for j= 1 :Ns Repara(:, 2 *j- 1 )=ReIChan0(:,j); Repara(:, 2 *j)=ReQChan(:,j); end ReSig=reshape(Repara, 1 ,para*Ns* 2 ); ReSig=ReSig> 0.5 ; |
- 1 回答
- 0 關(guān)注
- 90 瀏覽
添加回答
舉報(bào)
0/150
提交
取消