⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdpsk.m

📁 正交频分复用中当调制方式采用QDPSK时的解调程序
💻 M
字号:
%                   QDPSK调制                   %
% --------------------------------------------- %
carrier_matrix = [zeros(1,carrier_count); carrier_matrix];
% 添加一个差分调制的初始相位,为0
for i = 2:(symbols_per_carrier + 1)
carrier_matrix(i,:) = rem(carrier_matrix(i,:) + carrier_matrix (i-1,:), 2^bits_per_symbol) ;
% 差分调制 
end
carrier_matrix = carrier_matrix*((2*pi)/(2^bits_per_symbol)) ;
% 产生差分相位
[X, Y]=pol2cart(carrier_matrix, ones(size(carrier_matrix,1),size(carrier_matrix,2))); 
% 由极坐标向复数坐标转化 第一参数为相位 第二参数为幅度
% Carrier_matrix contains all the phase information and all the amplitudes
% are the same,‘1’.  
%---------------------------------------
% 函数说明:
%  POL2CART Transform polar to Cartesian coordinates.
%    [X,Y] = POL2CART(TH,R) transforms corresponding elements of data
%    stored in polar coordinates (angle TH, radius R) to Cartesian
%    coordinates X,Y.  The arrays TH and R must the same size (or
%    either can be scalar).  TH must be in radians.
% [X,Y,Z] = POL2CART(TH,R,Z) transforms corresponding elements of
%    data stored in cylindrical coordinates (angle TH, radius R, height Z) 
%    to Cartesian coordinates X,Y,Z. The arrays TH, R, and Z must be
%    the same size (or any of them can be scalar).  TH must be in radians.
%---------------------------------------
complex_carrier_matrix = complex(X, Y) ;
%---------------------------------------
% 函数说明:
%  COMPLEX Construct complex result from real and imaginary parts.
%    C = COMPLEX(A,B) returns the complex result A + Bi, where A and B are
%    identically sized real N-D arrays, matrices, or scalars of the same data type.
% 添加训练序列
training_symbols = [ 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 ...
-j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 ...
1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 ...
-1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j ...
-1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 1 j j 1 -1 -j -j -1 ]; 
% 25 times "1 j j 1" 
% 25 times "-1 -j -j -1"
% totally 200 symbols as a row
training_symbols = cat(1, training_symbols, training_symbols) ;  
training_symbols = cat(1, training_symbols, training_symbols) ;   
% Production of 4 rows of training_symbols
%-------------------------------------------------------------------------
% 函数说明:
% CAT Concatenate arrays.
%     CAT(DIM,A,B) concatenates the arrays A and B along the dimension DIM.  
%     CAT(2,A,B) is the same as [A,B].
%     CAT(1,A,B) is the same as [A;B].
%------------------------------------------------------------------------- 
%     B = CAT(DIM,A1,A2,A3,A4,...) concatenates the input
%     arrays A1, A2, etc. along the dimension DIM.
complex_carrier_matrix = cat(1, training_symbols, complex_carrier_matrix) ;
% 训练序列与数据合并 
% block-type pilot symbols
IFFT_modulation = zeros(4 + symbols_per_carrier + 1,IFFT_bin_length) ;
% % Here a row vector of zeros is between training symbols and data symbols!!! 
% % 4 training symbols and 1 zero symbol
% % every OFDM symbol takes a row of "IFFT_modulation" 
IFFT_modulation(: , carriers) = complex_carrier_matrix;
IFFT_modulation(: , conjugate_carriers) = conj(complex_carrier_matrix) ;
%-------------------------------------------------------------------------
%   Test by lavabin  -- Find the indices of zeros 
index_of_zeros = zeros(symbols_per_carrier,IFFT_bin_length - 2*carrier_count);
IFFT_modulation1 = zeros(4 + symbols_per_carrier + 1,IFFT_bin_length);
IFFT_modulation2 = zeros(4 + symbols_per_carrier + 1,IFFT_bin_length);
IFFT_modulation1(6:symbols_per_carrier+5,:) = IFFT_modulation(6:symbols_per_carrier+5,:)==0 ;
for i = 1:symbols_per_carrier
index_of_zeros(i,:) = find(IFFT_modulation1(i+5,:)==1);
end
%-------------------------------------------------------------------------
time_wave_matrix = ifft(IFFT_modulation') ; % 进行IFFT操作
time_wave_matrix = time_wave_matrix';
% If X is a matrix, ifft returns the inverse Fourier transform of each column of
% the matrix.
for i = 1: 4 + symbols_per_carrier + 1
windowed_time_wave_matrix( i, : ) = real(time_wave_matrix( i, : )) ;
end
% get the real part of the result of IFFT
% 这一步可以省略,因为IFFT结果都是实数
% 由此可以看出,只是取了IFFT之后载波上的点,并未进行CP的复制和添加end
ofdm_modulation = reshape(windowed_time_wave_matrix',1, IFFT_bin_length*(4 + symbols_per_carrier + 1) ) ;
% P2S operation
%-------------------------------------------------------------------------
%   Test by lavabin
%   Another way of matrix transition
ofdm_modulation_tmp = windowed_time_wave_matrix.';
ofdm_modulation_test = ofdm_modulation_tmp(:)';
if (ofdm_modulation_test == ofdm_modulation)
  fprintf('ofdm_modulation_test == ofdm_modulation \n\n\n');
else
  fprintf('ofdm_modulation_test ~= ofdm_modulation \n\n\n');
end 
% We get the result "ofdm_modulation_test == ofdm_modulation" .
%-------------------------------------------------------------------------
Tx_data = ofdm_modulation;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -