📄 ofdm_block_generation.m
字号:
function [ofdm_block,f] = ofdm_block_generation(code_block)
global H
% get N, AMP and M
s = get(H.edit8,'String');
N = st2de(s);
N = round(N);
s = get(H.edit18,'String');
AMP = st2de(s);
AMP = round(AMP);
% get B
s = get(H.edit21,'String');
B = st2de(s);
B = round(B);
s = get(H.edit12,'String');
M = st2de(s);
M = round(M);
% create blank frequency domain
f = zeros(1,N);
% create dc(direct current) and fc(carrier frequency) information
dc = 1;
fc = length(f) + 1;
% will be used for frequency assignments
% the frequencies that will be used are (n * 5) where n is 1, 2, 3, 4, etc.
n = 1;
% assign 8 bits to frequency domain 2 bits at a time
for k = 1:2:7,
% [0 0] is represented by a sine wave
if code_block(k:k + 1) == [0 0]
f(dc + (n * M)) = AMP - j * AMP;
f(fc - (n * M)) = AMP + j * AMP;
end
% [0 1] is represented by a -sine wave
if code_block(k:k + 1) == [0 1]
f(dc + (n * M)) = -AMP - j * AMP;
f(fc - (n * M)) = -AMP + j * AMP;
end
% [1 0] is represented by a cosine wave
if code_block(k:k + 1) == [1 0]
f(dc + (n * M)) = -AMP + j * AMP;
f(fc - (n * M)) = -AMP - j * AMP;
end
% % [1 1] is represented by a -cosine wave
if code_block(k:k + 1) == [1 1]
f(dc + (n * M)) = AMP + j * AMP;
f(fc - (n * M)) = AMP - j * AMP;
end
% increase frequency assinment
n = n + 1;
end
% create adjacent frequencies to our frequencies for use in phase shift
% compensation at receiving end
for k = 1:4,
f(dc + (k * M) + B) = AMP/3;
f(fc - (k * M) - B) = AMP/3;
end
% create ofdm_block from frequency information
ofdm_block = ifft(f);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -