• 大小: 22KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-10
  • 语言: Matlab
  • 标签: OFDM  matlab  

资源简介

ofdm的简单仿真matlab程序,里面画出了9格图可以更好的理解ofdm

资源截图

代码片段和文件信息

%--------1---------2---------3---------4---------5---------6---------7---------8
% OFDM Simulation
clear all;
close all;

% Basic OFDM system parameters
fprintf (‘OFDM Analysis Program\n\n‘);
defaults = input(‘To use default parameters input “1“ otherwise input “0“:  ‘);

if defaults == 1
    IFFT_bin_length = 1024;     % IFFT bin count for Tx FFT bin count for Rx
    carrier_count = 200;        % number of carriers
    bits_per_symbol = 2;        % bits per symbol  00011011
    symbols_per_carrier = 50;   % symbols per carrier
    SNR = 10;                   % channel signal to noise ratio (dB)                           
else
    IFFT_bin_length = input(‘IFFT bin length = ‘);
    carrier_count = input(‘carrier count = ‘);
    bits_per_symbol = input(‘bits per symbol = ‘);
    symbols_per_carrier = input(‘symbols per carrier =‘);
    SNR = input(‘SNR = ‘);
end

% Derived parameters
baseband_out_length =  carrier_count * symbols_per_carrier * bits_per_symbol; % 20000
carriers = (1:carrier_count) + (floor(IFFT_bin_length/4) - floor(carrier_count/2))% 从157-356共200个子载波
conjugate_carriers = IFFT_bin_length - carriers + 2; % 从869-670共200个子载波
% carriers 和 conjugate_carriers 是关于第513号载波对称的

%--------1---------2---------3---------4---------5---------6---------7---------8
% TRANSMIT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
% Generate a random binary output signal:
%   - a row of uniform random numbers (between 0 and 1) rounded to 0 or 1
%   - this will be the baseband signal which is to be transmitted.
baseband_out = round(rand(1baseband_out_length)); % 20000个随机数,0、1
% Convert to ‘modulo N‘ integers where N = 2^bits_per_symbol
%   - this defines how many states each symbol can represent
%   - first make a matrix with each column representing consecutive bits 
%     from the input stream and the number of bits in a column equal to the
%     number of bits per symbol
%   - then for each column multiply each row value by the power of 2 that 
%     it represents and add all the rows
%   - for example:  input 0 1 1 0 0 0 1 1 1 0
%                   bits_per_symbol = 2
%                   convert_matrix = 0 1 0 1 1
%                                    1 0 0 1 0

%                   modulo_baseband = 1 2 0 3 2
convert_matrix = reshape(baseband_out bits_per_symbol length(baseband_out)/bits_per_symbol); % 变成了一个2行10000列的矩阵
for k = 1:(length(baseband_out)/bits_per_symbol) % k=1:10000
    modulo_baseband(k) = 0;
    for i = 1:bits_per_symbol % i=1:2
        modulo_baseband(k) = modulo_baseband(k) + convert_matrix(ik)*2^(bits_per_symbol-i);
    end
end
% modulo_baseband 是一个1行10000列的向量,每个元素可能为[0,1,2,3]

%--------1---------2---------3---------4---------5---------6---------7---------8
% Serial to Parallel Conversion
%   - convert the serial modulo N stream into a matrix where each column 
%     represents a carrier and each row represents a symbol
%   - for example:
%

评论

共有 条评论