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

📄 xinhaofashe.m

📁 对正交频分复用中的信号发射利用matlab程序进行了仿真
💻 M
字号:
clear all;
close all;
fprintf( '\n OFDM仿真\n \n') ;
% --------------------------------------------- %
%                   参数定义                     %
% --------------------------------------------- %
IFFT_bin_length = 1024;
carrier_count   = 200;
bits_per_symbol = 2;
symbols_per_carrier = 50;
% 子载波数            200
% 位数/ 符号          2
% 符号数/ 载波        50
% 训练符号数          10
% 循环前缀长度        T/4(作者注明,不解为什么是该值)  All-zero CP  
% 调制方式            QDPSK
% 多径信道数          2、3、4(缺省)
% 信道最大时延        7 (单位数据符号)
% 仿真条件            收发之间严格同步 
SNR = input('SNR =') ;
% 输入信噪比参数
baseband_out_length = carrier_count * symbols_per_carrier * bits_per_symbol;
% 计算发送的二进制序列长度
carriers = (1: carrier_count) + (floor(IFFT_bin_length/4) - floor(carrier_count/2));   % 坐标: (1 to 200) + 156 ,  157 -- 356
conjugate_carriers = IFFT_bin_length - carriers + 2;    % 坐标 :1024 - (157:356) + 2 = 1026 - (157:356) = (869:670)     
% 构造共轭时间-载波矩阵,以便应用所谓的RCC,Reduced Computational Complexity算法,即ifft之后结果为实数 
% Define the conjugate time-carrier matrix
% 也可以用flipdim函数构造对称共轭矩阵
% --------------------------------------------- %
%                   信号发射                     %
% --------------------------------------------- %
out = rand(1,baseband_out_length);
baseband_out1 = round(out) ;
baseband_out2 = floor(out*2) ;
baseband_out3 = ceil(out*2)-1 ;
baseband_out4 = randint(1,baseband_out_length);
% 四种生成发送的二进制序列的方法,任取一种产生要发送的二进制序列
if (baseband_out1 == baseband_out2 & baseband_out1 == baseband_out3 )
fprintf('Transmission Sequence Generated \n \n');
baseband_out = baseband_out1 ;
else 
fprintf('Check Code!!!!!!!!!!!!!!!!!!!!! \n \n');
end
% 验证四种生成发送的二进制序列的方法
convert_matrix = reshape(baseband_out,bits_per_symbol,length(baseband_out)/bits_per_symbol) ;
% 函数说明:
% RESHAPE Change size.
%    RESHAPE(X,M,N) returns the M-by-N matrix whose elements
%    are taken columnwise from X.  An error results if X does
%    not have M*N elements.
for k = 1:(length(baseband_out)/bits_per_symbol)
  modulo_baseband(k) = 0 ;
for i = 1:bits_per_symbol
  modulo_baseband(k) =  modulo_baseband(k) + convert_matrix(i,k)*2^(bits_per_symbol - i) ;
end
end
% 每2个比特转化为整数 0至3
% 采用'left-msb'方式
%-------------------------------------------------------------------------
%  Test by lavabin
%  A built-in function of directly change binary bits into decimal numbers
%-------------------------------------------------------------------------
convert_matrix1 = zeros(length(baseband_out)/bits_per_symbol,bits_per_symbol);
convert_matrix1 = convert_matrix' ;
Test_convert_matrix1 = bi2de(convert_matrix1,bits_per_symbol,'left-msb');
Test_convert_matrix2 = bi2de(convert_matrix1,bits_per_symbol,'right-msb');
% 函数说明:
%  BI2DE Convert binary vectors to decimal numbers.
%     D = BI2DE(B) converts a binary vector B to a decimal value D. When B is
%     a matrix, the conversion is performed row-wise and the output D is a
%     column vector of decimal values. The default orientation of the binary
%     input is Right-MSB; the first element in B represents the least
%     significant bit.
if (modulo_baseband == Test_convert_matrix1') 
    fprintf('modulo_baseband = Test_convert_matrix1 \n\n\n');
else if (modulo_baseband == Test_convert_matrix2')      
    fprintf('modulo_baseband = Test_convert_matrix2 \n\n\n');
    else
    fprintf('modulo_baseband ~= any Test_convert_matrix \n\n\n'); 
    end
end
% we get the result "modulo_baseband = Test_convert_matrix1".
%-------------------------------------------------------------------------
    
carrier_matrix = reshape(modulo_baseband,carrier_count,symbols_per_carrier)';  
% 生成时间-载波矩阵

⌨️ 快捷键说明

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