那位高手指点一下OFDM的基本仿真,用MATLAB,谢谢了
我有本书讲OFDM的MATLAB方针(电子版)。。。
有机会上传到FTP上。。。
呵呵,误会...
不是我写的...
我下一本书...
这里牛人太多了...
牛眼里边看的,可能都是牛人吧...
%
% FUNCTION 2.10 : "cp0203_qpsk_mod"
%
% This function receives a binary stream in input ('bits')
% and returns the corresponding sequence of QPSK symbols
% ('S'),
% plus the two sequences 'Sc' and 'Ss' containing the real
% and imaginary part of each symbol
%
% Programmed by Guerino Giancola
%
function [S,Sc,Ss] = cp0203_qpsk_mod(bits)
nb = length(bits); % number of bits
ns = ceil(nb/2); % number of symbols
b0 = zeros(1,ns*2); % zero padding
b0(1:nb) = bits;
j = sqrt(-1);
for s = 1 : ns
ba = b0(((s-1)*2)+1);
bb = b0(((s-1)*2)+2);
k = bb + ba*2;
p = ((pi/4)*(2*k-1))-pi;
Sc(s) = cos(p);
Ss(s) = sin(p);
S(s) = Sc(s) + j*Ss(s);
end
%
% FUNCTION 2.11 : "cp0203_OFDM_qpsk"
%
% Simulation of a transmitter implementing
% the OFDM transmission chain with QPSK modulation
% on each sub-carrier
%
% 'numbits' is the number of bits generated by the source
% 'fp' is the carrier frequency of the generated signal
% 'fc' is the sampling frequency
% 'T0' is the block length in [s], i.e., 1/T0 is the carrier
% separation
% 'TP' is the length of the cyclic prefix [s]
% 'TG' is guard time
% 'A' is the amplitude of the rectangular impulse response
% [V]
% 'N' is the number of carriers (tones) used in the OFDM
% system
%
% The function returns:
% 1) the generated stream of bits ('bits')
% 2) the corresponding stream of QPSK symbols ('S')
% 3) the I component of the generated signal ('SI')
% 4) the Q component of the generated signal ('SQ')
% 5) the generated OFDM signal ('Stx')
% 6) the value of the sampling frequency ('fc')
% 7) the value of the carrier frequency ('fp')
% 8)9)10) the values of T0, TP, and TG
% 11) the number of tones used for transmission
%
% Programmed by Guerino Giancola
%
function [bits,S,SI,SQ,Stx,fc,fp,T0,TP,TG,N] = ...
cp0203_OFDM_qpsk;
% ----------------------------
% Step Zero - Input parameters
% ----------------------------
numbits = 1024; % number of bits to be transmitted
fp = 1e9; % central frequency
fc = 50e9; % sampling frequency
T0 = 242.4e-9; % information length
TP = 60.6e-9; % cyclic prefix
TG = 70.1e-9; % total guard time
A = 1; % amplitude of the rectangular impulse
% response
N = 128; % number of carriers of the OFDM
% system
% -------------------------
% Step One - OFDM modulator
% -------------------------
tc = T0 / N; % chip time
ntcp = floor(TP/tc); % number of tones of the cyclic
% prefix
n = (-ntcp+1:1:N); % tone counter
NT = length(n); % total number of tones per symbol
% Bit generation
bits=rand(1,numbits)>0.5;
% QPSK modulator
[S,Sc,Ss] = cp0203_qpsk_mod(bits);
% OFDM modulator
nb = ceil(length(S)/N); % number of OFDM blocks to be
% transmitted
S0 = zeros(1,nb*N); % zero padding
S0(1:length(S))=S;
dt = 1 / fc; % sampling period
if ntcp>0
tc = (T0+TP)/NT; % tone duration
end
tonesamples = floor(tc/dt); % samples per tone
toneres = floor((TG-TP)/dt); % samples for the residual
% part
symsamp = (tonesamples*NT)+toneres;
% number of samples representing one OFDM symbol
totsamp = symsamp * nb;
% number of samples representing the transmitted signal
X = [zeros(1,totsamp)'];
for b = 1 : nb
% Serial to Parallel conversion and zero padding
c = S0((1+(b-1)*N):(N+(b-1)*N)); % block extraction
A = length(c);
a1 = floor(A/2);
a2 = A - a1;
FS = 2*A;
Czp=zeros(FS,1);
Czp(1:a1)=[c(1:a1).'];
Czp(FS-a2+1:FS)=[c(A-a2+1:A).'];
C = ifft(Czp); % IFFT of the zero-padded input
if ntcp>0 % insertion of the cyclic prefix
C1=zeros(length(C)+2*ntcp,1);
C1(1:(2*ntcp))=C(2*N+1-(2*ntcp):2*N);
C1(2*ntcp+1:length(C1))=C;
else
C1=C;
end
%
zp = floor(tonesamples/2);
C2 = [C1.';zeros((zp-1),length(C1))];
C3 = C2(:);
g = ones(1,zp);
C4 = conv(g,C3);
C4 = C4(1:(zp*NT*2));
ics = 1 + (b-1)*symsamp + toneres;
X(ics:ics+length(C4)-1)=C4;
end % for b = 1 : nb
XM = X'; % Parallel to Serial conversion
XM = XM(1:totsamp);
I = real(XM);
Q = imag(XM);
% carrier modulation
time = linspace(0,totsamp*dt,length(I));
SI = I(cos((2*pi*fp)time));
SQ = Q(sin((2*pi*fp)time));
Stx = SI - SQ;
谢谢大家了!
相关文章:
- 请问有没有简单的用matlab进行波束形成仿真的程序(05-08)
- 请教OPNET与NS2仿真模型(05-08)
- 求助,卷积码的软判决维特比译码的matlab仿真!(05-08)
- 请问系统级仿真与链路级仿真有什么不同,谢谢。(05-08)
- 请教Rayleigh信道仿真的参考文献(05-08)
- OFDM仿真中信道过采样的问题(05-08)