实验:OFDM原理与实现
一、实验内容
学习CP-OFDM实现代码
• 实现CP-SCFDE
• 实现ZP-OFDM
• 实现ZP-SCFDE
• 比较分析四种技术的识码率性能
• 分析ZP-OFDM/SCFDE两种方案的复杂度
• 探讨是否有降低ZP-OFDM与ZP-SCFDE均衡复杂
的可能性(选做)
1、学习CP-OFDM实现代码
(1)代码
N = 256; % 载波数, i.e., fft size
Ncp= N/4; % 循环前缀的长度
Ns = N + Ncp; %每个OFDM符号的整个长度
Ntry = 100; % OFDM帧的数量
Nsyb = 20; % 每帧的OFDM符号的数目
M = 16; %M-ary QAM
m = log2(M); % m bits per subcarrier
Pav = 2*(M-1)/3.0; % 每个子载波的平均功率
PavdB = 10*log10(Pav/N);% 时间信号的分贝平均值
SNRdB = [0:5:40]; % SNR list to be simulated
% Set multi-path fading channel parameters
Np = Ncp/4; 朗诵背景音乐纯音乐% The number of multipaths
% idxTaps = sort(randperm(Ncp,Np));% After matlab 2012a
idxTaps = randperm(Ncp); % before matlab 2012a
idxTaps = sort(idxTaps(1:Np)); % before matlab 2012a
idxTaps - idxTaps(1)+1; % Move the first multipath to 0 delay
DPS = exp(-3*idxTaps/Ncp);% power in each tap: Delay Power Spectrum
DPS = DPS/sum(DPS); % Normalize
Ampath = sqrt(DPS); 家园共育案例% Amplitude of each path
一句话表白%% Directly u Matlab channel object
% SymbolRate = 20e6; % Sampling Rate
% Ts = 1/SymbolRate; % Symbol period
% Tau = (idxTaps-1)* Ts; % tap delay in s
繁殖是什么意思
% PdB = 10*log10(DPS); % Delay Power Spectrum in dB
% Fdop = 0; % Quasi-static channels
% ch = rayleighchan(Ts, Fdop, Tau, PdB);
% ch.StorePathGains = 1; % Flag to store path gain
hzero = zeros(Ncp,1); % zero vector for channel impul respon
ErrSymbols = zeros(size(SNRdB)); % store the number of the error symbols
tic % the instant begin simulation
for numSimSymbols = 1 : Ntry
curErrSymbols = 0;
% Step 1: Generate random digital message
d = randi([0,M-1],N,Nsyb); % Message signal
% Step 2: M-QAM modulation.
X = qammod(d,M);
% Step 3: IFFT, generate time field signal,
鲜炖燕窝% i.e., modulate at frequency Field,
x = ifft(X);
% Step 4: Ìí¼ÓÑ»·Ç°×º
xcp = [x(N-Ncp+1:end,:);x];
% Serialize
xcp = xcp(:);
% Step 5a: Transmit through Channel
% Mannully Generate multipath channel impul respon
cir = Ampath.* ( randn(1,Np) + 1j*randn(1,Np))/sqrt(2);
h = hzero; h(idxTaps) = cir.'; % store channel
% Channel effect
xcpch = zeros(Ns *Nsyb+Ncp,1);
for p = 1:Np
idx = [0:Ns *Nsyb-1]+idxTaps(p);
xcpch(idx) = xcpch(idx) + cir(p)*xcp;
end
xcpch = xcpch(1:Ns *Nsyb);
% Can also u Matlab chanel object
% xcpch = filter(ch, xcp);
% h = hzero; h(idxTaps) = ch.PathGains;% Save channel
for k=1:length(SNRdB)
% Step 5b: AWGN
y = awgn(xcpch,SNRdB(k),'measured');组网方式%PavdB);
% Step 6: Delete CP
y = reshape(y,[Ns,Nsyb]);
y = y([Ncp+1:end],:);
% Step 7: FFT, Come back to Frequency Field
Y = fft(y);
硝酸铜的化学式 % Step 8: Frequency domain equalization
HCP = fft(h,N);% Channel Frequency Respon of Prefect channel
Gzf = 1./HCP; % Zero-Forcing Equalizer
Xhat= Y .* repmat(Gzf,[1,Nsyb]);
% Step 9: Demodulate, to recover the message.
dhat = qamdemod(Xhat,M);
% Step 10: Compute symbol error rate.
ddif = d - dhat; ddif = ddif(:);
的确的近义词 curErrSymbols = length(find(ddif~= 0));
ErrSymbols(k) = ErrSymbols(k) + curErrSymbols;
end
end
toc %simulation time
% Step 10: Show simulation results
cpSER = ErrSymbols / (N*Nsyb*Ntry);
% Theory SER of M-ary QAM in flat Fading Channel
SNR = 10.^(SNRdB/10);
EbNo =10*log10(SNR/m);
[thyBER,thySER] = berfading(EbNo,'qam',M,1)
figure; milogy(SNRdB, [cpSER;thySER],'-o');
xlabel('SNRdB'); ylabel('Symbol error ratio (SER)');
legend('Simulated CP-OFDM in multipath fading','Theoretical M-QAM in flat fading');grid on;
(2)结果
(3)分析