📄 cp0203_ofdm_qpsk.asv
字号:
%
% 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 lenght 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 [X] = cp0203_OFDM_qpsk[bits,N];
% ----------------------------
% Step Zero - Input parameters
% ----------------------------
numbits = 2032; % number of bits to be transmitted 127*n
%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] = cp0201_bits(numbits);
% QPSK modulator
[S,Sc,Ss] = cp0203_qpsk_mod(bits);
% OFDM modulator
nb = ceil(length(S)/(N-1)); % 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)'];
X = zeros(1,(2*N+2*ntcp)*nb);
for b = 1 : nb
c = S0((1+(b-1)*(N-1)):(N-1+(b-1)*(N-1))); % block extraction
% S/P conversion and zero padding
A = length(c);
% a1 = floor(A/2);
% a2 = A - a1;
% FS = 2*A;
Czp=zeros(1,A);
Czp(1:A)=c(1:A);
%Czp(1+A:2*A)=[conj(c(N:-1:1)).']
%Czp(FS-a2+1:FS)=[c(A-a2+1:A).'];
Czp=[0 Czp 0 conj(Czp(A:-1:1))];
C = ifft(Czp); % IFFT of the zero-padded input
if ntcp>0 % Insertion of the cyclic prefix
C1=zeros(1,length(C)+2*ntcp);
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(1+(2*N+2*ntcp)*(b-1):2*N+2*ntcp+(2*N+2*ntcp)*(b-1))=C1;
end % for b = 1 : nb
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -