《Matlab简单的OFDM仿真信道估计有BER曲线》由会员分享,可在线阅读,更多相关《Matlab简单的OFDM仿真信道估计有BER曲线(9页珍藏版)》请在金锄头文库上搜索。
1、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=);
2、% 输入信噪比参数SNR=3:14;%定义信噪比范围BER=zeros(1,length(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 - 356conjugate_carriers=IFFT_bin_length-carriers
3、+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(
4、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)
5、;%end% 验证四种生成发送的二进制序列的方法baseband_out=round( rand(1,baseband_out_length);convert_matrix = reshape(baseband_out,bits_per_symbol,length(baseband_out)/bits_per_symbol);for k = 1length(baseband_out)/bits_per_symbol),modulo_baseband(k) = 0; for i = 1:bits_per_symbol modulo_baseband(k) = modulo_baseband(k)
6、 + 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_con
7、vert_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 perf
8、ormed row-wise and the output D is a% column vector of decimal values. The default orientation of thebinary% 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 nnn);%else if (mo
9、dulo_baseband = Test_convert_matrix2) % fprintf(modulo_baseband = Test_convert_matrix2 nnn);% else% fprintf(modulo_baseband = any Test_convert_matrix nnn); % end%end% we get the result modulo_baseband = Test_convert_matrix1.%-carrier_matrix = reshape(modulo_baseband,carrier_count,symbols_per_carrier
10、);% 生成时间载波矩阵% - % QDPSK调制 % - %carrier_matrix = zeros(1,carrier_count); carrier_matrix;% 添加一个差分调制的初始相位,为0for i = 2symbols_per_carrier + 1) carrier_matrix(i, = rem(carrier_matrix(i, + carrier_matrix (i-1, 2bits_per_symbol) ;% 差分调制 endcarrier_matrix = carrier_matrix*(2*pi)/(2bits_per_symbol) ;% 产生差分相位
11、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 same1. complex_carrier_matrix = complex(X, Y) ;% 添加训练序列 training_symbols = 1 j j 1 -1 -j -j -1 1 j j 1 -1
12、-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
13、-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 rowtraining_symbols = cat(1, training_symbols, training_symbols) ;training_symbols = cat(1, training_symbols, tr