1 回答

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊
function [ output_args ] = Untitled1( input_args )
%UNTITLED1 Summary of this function goes here
% Detailed explanation goes here
%數(shù)據(jù)調(diào)制采用QPSK
clear;
clc; %clc是清除當(dāng)前command區(qū)域的命令,表示清空,看著舒服些 。而clear用于清空環(huán)境變量
SNR=10; % 信噪比
Nfft=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)度
Signal=rand(1,para*Ns*2)>0.5;%產(chǎn)生0,1 隨即序列,符號(hào)數(shù)為para*Ns*2
%(子信道個(gè)數(shù)×調(diào)制水平×每個(gè)子信道中有用符號(hào)個(gè)數(shù))
for i=1:para
for j=1:Ns*2
SigPara(i,j)=Signal(i*j);%串并變換
%將隨機(jī)產(chǎn)生的二進(jìn)制矩陣變換為行數(shù)為para,列數(shù)為2*Ns的矩陣
end
end
%QPSK調(diào)制,將數(shù)據(jù)分為兩個(gè)通道
for j=1:Ns
ich(:,j)=SigPara(:,2*j-1);
qch(:,j)=SigPara(:,2*j);
end
kmod=1./sqrt(2);
ich1=ich.*kmod;
qch1=qch.*kmod;
x=ich1+qch1.*sqrt(-1); %頻域數(shù)據(jù)變時(shí)域
y=ifft(x);
ich2=real(y);
qch2=imag(y);
%插入保護(hù)間隔
ich3=[ich2(Nfft-gl+1:Nfft,:);ich2];
qch3=[qch2(Nfft-gl+1:Nfft,:);qch2];
%并串變換
ich4=reshape(ich3,1,(Nfft+gl)*Ns);
qch4=reshape(qch3,1,(Nfft+gl)*Ns);
%形成復(fù)數(shù)發(fā)射數(shù)據(jù)
TrData=ich4+qch4.*sqrt(-1);
%接收機(jī)
%加入高斯白噪聲
ReData=awgn(TrData,SNR,'measured');
%接收端
%移去保護(hù)間隔
idata=real(ReData);
qdata=imag(ReData);
idata1=reshape(idata,Nfft+gl,Ns);
qdata1=reshape(qdata,Nfft+gl,Ns);
idata2=idata1(gl+1:gl+Nfft,:);
qdata2=qdata1(gl+1:gl+Nfft,:);
%FFT
Rex=idata2+qdata2*sqrt(-1);
ry=fft(Rex);
ReIChan=real(ry);
ReQChan=imag(ry);
ReIchan=ReIChan/kmod;
ReQchan=ReQChan/kmod;
%QPSK逆映射
for j=1:Ns
RePara(:,2*j-1)=ReIChan(:,j);
RePara(:,2*j)=ReQChan(:,j);
end
ReSig=reshape(RePara,1,para*Ns*2);
%符號(hào)抽樣判決
ReSig=ReSig>0.5;
figure(1);
subplot(2,1,1),stem(ReSig(1:20)),grid minor;
title('resignal');
xlabel('x'),ylabel('y');
subplot(2,1,2),stem(Signal(1:20)),grid;
title('signal');
你的程序缺好多參數(shù),已補(bǔ)全~
- 1 回答
- 0 關(guān)注
- 142 瀏覽
添加回答
舉報(bào)