• Joefan
    了解作者
  • matlab
    开发工具
  • 10.1KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 5 积分
    下载积分
  • 4
    下载次数
  • 2022-04-18 17:28
    上传日期
基于OFDM的雷达测距测速MATLAB代码
Radar.zip
  • demoduqam32.m
    1.2KB
  • qam8.m
    686B
  • qam4.m
    641B
  • demoduqam64.m
    1.8KB
  • m_generate.m
    285B
  • demoduqam4.m
    704B
  • demoduqam8.m
    749B
  • qam64.m
    1.7KB
  • qam16.m
    688B
  • qam32.m
    1.2KB
  • OFDM_radar_v3_PAPR.m
    16.4KB
  • demoduqam16.m
    851B
  • rcoswindow.m
    366B
内容介绍
%% clear; close all; carrier_count=200;%子载波数 symbols_per_carrier=12;%OFDM符号数 bits_per_symbol=2;%每个调制符号的比特数(4QAM对应的就是2) % bits_per_symbol=3;%每个调制符号的比特数(8QAM对应的就是3) % bits_per_symbol=4;%每个调制符号的比特数(16QAM对应的就是4) % bits_per_symbol=5;%每个调制符号的比特数(32QAM对应的就是5) % bits_per_symbol=6;%每个调制符号的比特数(64QAM对应的就是6) IFFT_bin_length=512;%FFT点数 PrefixRatio=1/4;%循环前缀比率 1/6~1/4 GI=PrefixRatio*IFFT_bin_length ;%循环前缀的长度 beta=1/32;%循环后缀比率 GIP=beta*(IFFT_bin_length+GI);%循环后缀长度 SNR=10; %信噪比,单位是dB %% 基本参数设置 c = 3*10^8; % 电磁波传播速度, 单位m/s delta_f = 240*10^3; % 载波间隔,单位hz f_c = 24*10^9; % 信号中心频偏, 单位hz %% ================发送数据生成=================================== baseband_out_length = carrier_count * symbols_per_carrier * bits_per_symbol;%发送比特长度 200*12*4 carriers = (1:carrier_count) + (floor(IFFT_bin_length/4) - floor(carrier_count/2));%计算OFDM符号子载波的序号,carriers中存放的序号是29-228 conjugate_carriers = IFFT_bin_length - carriers + 2; %计算OFDM符号子载波的序号,conjugate_carries中存放的序号是282-481, 实际是485-286 %% ***************模拟随机通信信息*************** % baseband_out=zeros(1,baseband_out_length);%纯0序列 %% ***************模拟随机通信信息*************** baseband_out=ones(1,baseband_out_length);%纯1序列 %% ***************模拟随机通信信息*************** % rand( 'twister',0); %随机种子,可以让每次生成的随机数有规律 % baseband_out=round(rand(1,baseband_out_length));%生成随机数(模拟随机的通信数据) %% ***************m序列*************** % %================================================== % % rand( 'twister',0); 有了这句话每次生成的随机数具有一样的规律 % Tx_matric = zeros(carrier_count*bits_per_symbol,symbols_per_carrier); % for i = 1:symbols_per_carrier % Order_number=10; %m序列的阶数等于10,m序列长度为2^10 - 1 % mg = zeros(carrier_count*bits_per_symbol,1); % % mg(1:carrier_count*bits_per_symbol-1,1) =idinput((2^(Order_number)-1),'prbs')';%采用idinput函数可以生成多种序列,生成m序列 % %本源多项式的系数,可以用primpoly(Order_number,'all')得到; % tmp = primpoly(Order_number,'all'); %生成所有可行的m序列的本源多项式系数,阶数越大,数越多(常数项系数不考虑) % cur_tmp = int32(tmp(1)); %选择第一个 % f = zeros(1,Order_number+1); % for j = 1:Order_number+1 % if mod(cur_tmp,2) == 1 % f(j) = 1; % end % cur_tmp = idivide(int32(cur_tmp),int32(2),'floor'); % end % f = f(1,2:Order_number+1); % tmp = m_generate(f); % mg(1:carrier_count*bits_per_symbol-1,1) = tmp(1:carrier_count*bits_per_symbol-1); % Tx_matric(:,i) = mg; % end % baseband_out = reshape(Tx_matric,1,baseband_out_length); % %% ==============4QAM调制==================================== complex_carrier_matrix=qam4(baseband_out); complex_carrier_matrix=reshape(complex_carrier_matrix',carrier_count,symbols_per_carrier)';%symbols_per_carrier*carrier_count figure(1); plot(complex_carrier_matrix,'*r'); title('star map of Tx_data'); axis([-2, 2, -2, 2]); grid on % %% ==============8QAM调制==================================== % % complex_carrier_matrix=qam8(baseband_out); % % complex_carrier_matrix=reshape(complex_carrier_matrix',carrier_count,symbols_per_carrier)';%symbols_per_carrier*carrier_count % % figure(1); % plot(complex_carrier_matrix,'*r'); % title('star map of Tx_data'); % axis([-2, 2, -2, 2]); % grid on % %% ==============16QAM调制==================================== % % complex_carrier_matrix=qam16(baseband_out); % % complex_carrier_matrix=reshape(complex_carrier_matrix',carrier_count,symbols_per_carrier)';%symbols_per_carrier*carrier_count % % figure(1); % plot(complex_carrier_matrix,'*r'); % title('star map of Tx_data'); % axis([-4, 4, -4, 4]); % grid on % %% ==============32QAM调制==================================== % % complex_carrier_matrix=qam32(baseband_out); % % complex_carrier_matrix=reshape(complex_carrier_matrix',carrier_count,symbols_per_carrier)';%symbols_per_carrier*carrier_count % % figure(1); % plot(complex_carrier_matrix,'*r'); % title('star map of Tx_data'); % axis([-8, 8, -8, 8]); % grid on % %% ==============64QAM调制==================================== % % complex_carrier_matrix=qam64(baseband_out); % % complex_carrier_matrix=reshape(complex_carrier_matrix',carrier_count,symbols_per_carrier)';%symbols_per_carrier*carrier_count % % figure(1); % plot(complex_carrier_matrix,'*r'); % title('star map of Tx_data'); % axis([-8, 8, -8, 8]); % grid on %% =================IFFT=========================== IFFT_modulation=zeros(symbols_per_carrier,IFFT_bin_length); IFFT_modulation(:,carriers ) = complex_carrier_matrix ; IFFT_modulation(:,conjugate_carriers ) = conj(complex_carrier_matrix); %======================================================== figure(2); stem(0:IFFT_bin_length-1, abs(IFFT_modulation(2,1:IFFT_bin_length)),'b*-') grid on axis ([0 IFFT_bin_length -0.5 4.5]); ylabel('Magnitude'); xlabel('IFFT Bin'); title('OFDM Carrier Frequency Magnitude'); figure(3); plot(0:IFFT_bin_length-1, (180/pi)*angle(IFFT_modulation(2,1:IFFT_bin_length)), 'go') hold on stem(0:carriers-1, (180/pi)*angle(IFFT_modulation(2,1:carriers)),'b*-'); stem(0:conjugate_carriers-1, (180/pi)*angle(IFFT_modulation(2,1:conjugate_carriers)),'b*-'); axis ([0 IFFT_bin_length -200 +200]) grid on ylabel('Phase (degrees)') xlabel('IFFT Bin') title('OFDM Carrier Phase') %================================================================= signal_after_IFFT=ifft(IFFT_modulation,IFFT_bin_length,2);%ifft time_wave_matrix =signal_after_IFFT; figure(4); subplot(3,1,1); plot(0:IFFT_bin_length-1,time_wave_matrix(2,:)); axis([0, 700, -0.2, 0.2]); grid on; ylabel('Amplitude'); xlabel('Time'); title('OFDM Time Signal, One Symbol Period'); %% =====================加循环前缀CP和后缀==================================== XX=zeros(symbols_per_carrier,IFFT_bin_length+GI+GIP);%GI=128,GIP=20 for k=1:symbols_per_carrier %12 for i=1:IFFT_bin_length %512 XX(k,i+GI)=signal_after_IFFT(k,i);%129--640 end for i=1:GI %1--128 XX(k,i)=signal_after_IFFT(k,i+IFFT_bin_length-GI);%加循环前缀CP end for j=1:GIP XX(k,IFFT_bin_length+GI+j)=signal_after_IFFT(k,j);%加循环后缀 end end time_wave_matrix_cp=XX; %iFFT_bin_length+GI+GIP=660 subplot(3,1,2); plot(0:length(time_wave_matrix_cp)-1,time_wave_matrix_cp(2,:)); axis([0, 700, -0.2, 0.2]); grid on; ylabel('Amplitude'); xlabel('Time'); title('OFDM Time Signal with CP, One Symbol Period'); %% ***************OFDM符号加窗操作****************** windowed_time_wave_matrix_cp=zeros(1,IFFT_bin_length+GI+GIP); for i = 1:symbols_per_carrier %12 windowed_time_wave_matrix_cp(i,:) = real(time_wave_matrix_cp(i,:)).*rcoswindow(beta,IFFT_bin_length+GI)'; end subplot(3,1,3); plot(0:IFFT_bin_length-1+GI+GIP,windowed_time_wave_matrix_cp(2,:)); axis([0, 700, -0.2, 0.2]); grid on; ylabel('Amplitude'); xlabel('Time'); title('OFDM Time Signal Apply a Window , One Symbol Period'); windowed_Tx_data=zeros(1,symbols_per_carrier*(IFFT_bin_length+GI)+GIP); windowed_Tx_data(1:IFFT_bin_length+GI+GIP)=windowed_time_wave_matrix_cp(1,:); for i = 1:symbols_per_carrier-1 windowed_Tx_data((IFFT_bin_length+GI)*i+1:(IFFT_bin_length+GI)*(i+1)+GIP)=windowed_time_wave_matrix_cp(i+1,:); end %======================================================= Tx_data_withoutwindow =reshape(time_wave_matrix_cp',(symbols_per_carrier)*(IFFT_bin_length+GI+GIP),1)';%未加窗 Tx_data =reshape(windowed_time_wave_matrix_cp',(symbols_per_carrier)*(IFFT_bin_length+GI+GIP),1)';%加窗 %================================================================= temp_time1 = (symbols_per_carrier)*(IFFT_bin_length+GI+G
评论
    相关推荐