📄 myofdm.asv
字号:
clear all;
fprintf ('OFDM Analysis Program\n\n');
Btot=100 % total bits per OFDM symbol
N = 64; % number of symbols in a single OFDM symbol
gap=8 ; % gap
% create channel
[H h_f]=create_channel(Mt, Mr, A, N+GI);
% bitloading
[bits_alloc,energy_alloc] = BitLoad(S,Btot,Mt*N,gap,sig2,M);
% bits to transmit% Generate a random binary output signal:
x = (randn(1,Btot)>0);
% modulation
complex_carrier_matrix = modulate(x,bits_alloc,energy_alloc, s2,s4,s16,s64,s256);
% Assign each carrier to its IFFT bin
% Transform each period's spectrum (represented by a row of carriers) to the
% time domain via IFFT
IFFT_modulation = zeros(symbols_per_carrier + 1, IFFT_bin_length);
IFFT_modulation(:,carriers) = complex_carrier_matrix;
IFFT_modulation(:,conjugate_carriers) = conj(complex_carrier_matrix);
%% Transform each period's spectrum (represented by a row of carriers) to the time domain via IFFT
%
time_wave_matrix = ifft(IFFT_modulation');
time_wave_matrix = time_wave_matrix';
for f = 1:carrier_count
temp_bins(1:IFFT_bin_length)=0+0j;
temp_bins(carriers(f))=IFFT_modulation(2,carriers(f));
temp_bins(conjugate_carriers(f))=IFFT_modulation(2,conjugate_carriers(f));
temp_time = ifft(temp_bins');
figure(4)
%plot(0:IFFT_bin_length-1, temp_time, colors(f))
plot(0:IFFT_bin_length-1, temp_time)
hold on
end
% Apply a Window Function to each time waveform
for i = 1:symbols_per_carrier + 1
%windowed_time_wave_matrix(i,:) = real(time_wave_matrix(i,:)) .* hamming(IFFT_bin_length)';
windowed_time_wave_matrix(i,:) = real(time_wave_matrix(i,:));
end
ofdm_modulation = reshape(windowed_time_wave_matrix', 1, IFFT_bin_length*(symbols_per_carrier+1));
%
% PLOT OFDM SIGNAL (time)
%
temp_time = IFFT_bin_length*(symbols_per_carrier+1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -