• 大小: 0.01M
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-07
  • 语言: Matlab
  • 标签: 其他  

资源简介

OFDM图.m

资源截图

代码片段和文件信息

clear all;
close all;
IFFT_bin_length=1024;
carrier_count=200;
bits_per_symbol=2;
symbols_per_carrier=50;
SNR=10;
baseband_out_length=carrier_count*symbols_per_carrier*bits_per_symbol;%总比特数
carriers=(1:carrier_count)+(floor(IFFT_bin_length/4)-floor(carrier_count/2));
conjugate_carriers=IFFT_bin_length-carriers+2;
%发送端
%产生随即二进制数据:
baseband_out=round(rand(1baseband_out_length));
convert_matrix=reshape(baseband_outbits_per_symbollength(baseband_out)/bits_per_symbol);
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(ik)*2^(bits_per_symbol-i);
   end
end
%串并转换
carrier_matrix=reshape(modulo_basebandcarrier_countsymbols_per_carrier)‘;
%对每个载波的符号进行差分编码
carrier_matrix=[zeros(1carrier_count);carrier_matrix];
for i=2:(symbols_per_carrier+1)
    carrier_matrix(i:)=rem(carrier_matrix(i:)+carrier_matrix(i-1:)2^bits_per_symbol);
end
%把差分符号代码转换成相位
carrier_matrix=carrier_matrix*((2*pi)/(2^bits_per_symbol));
%把相位转换成复数
[XY]=pol2cart(carrier_matrixones(size(carrier_matrix1)size(carrier_matrix2)));
complex_carrier_matrix=complex(XY);
%分配载波到指定的IFFT位置
IFFT_modulation=zeros(symbols_per_carrier+1IFFT_bin_length);
IFFT_modulation(:carriers)=complex_carrier_matrix;
IFFT_modulation(:conjugate_carriers)=conj(complex_carrier_matrix);
%画出频域中的OFDM信号代表
figure(1)
stem(0:IFFT_bin_length-1abs(IFFT_modulation(21:IFFT_bin_length))‘b*-‘)
grid on
axis([0 IFFT_bin_length -0.5 1.5])
ylabel(‘Maginitude‘)
Xlabel(‘IFFT Bin‘)
title(‘OFDM Carrier Frequenxy Magnitude‘)

figure(2)
plot(0:IFFT_bin_length-1(180/pi)*angle(IFFT_modulation(21:IFFT_bin_length))‘go‘)
hold on
stem(carriers-1(180/pi)*angle(IFFT_modulation(2carriers))‘b*-‘)
stem(conjugate_carriers-1(180/pi)*angle(IFFT_modulation(2conjugate_carriers))‘b*-‘)
axis([0 IFFT_bin_length -200 +200])
grid on
ylabel(‘Phase(degrees)‘)
Xlabel(‘IFFT Bin‘)
title(‘OFDM Carrier Phase‘)
%通过IFFT将频域转化为时域信号,得到时域信号
time_wave_matrix=ifft(IFFT_modulation‘);
time_wave_matrix=time_wave_matrix‘;

figure(3)
plot(0:IFFT_bin_length-1time_wave_matrix(2:))
grid on
ylabel(‘Amplitude‘)
xlabel(‘Time‘)
title(‘OFDM Time SignalOne Symbol Period‘)

%画出每个载波对应的时域信号(分离的OFDM信号)3131313131313131
for f=1:carrier_count
    temp_bins(1:IFFT_bin_length)=0+0j;
    temp_bins(carriers(f))=IFFT_modulation(2carriers(f));
    temp_bins(conjugate_carriers(f))=IFFT_modulation(2conjugate_carriers(f));
    temp_time=ifft(temp_bins‘);

end
 figure(4)
    plot(0:IFFT_bin_length-1temp_time)
    hold on

grid on
ylabel(‘Amplitude‘)
xlabel(‘Time‘)
title(‘Separated Time Waveforms Carriers‘)
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‘1IFFT_bin_length*(symbols_per_carrier

评论

共有 条评论