雷达模糊函数及MATLAB仿真(二)https://developer.aliyun.com/article/1472372
6、二进制相位编码
巴克码是二进制相位编码中的一族,它产生的压缩后的波形具有恒等于单位值的旁瓣电平。
相位编码的通用形式:
巴克码自相关函数:
①、MATLAB 源码
Barker_ambig.m
function [ambig] = barker_ambig(uinput) % Compute and plot the ambiguity function for a Barker code %Compute the ambiguity function % by utilizing the FFT through combining multiple range cuts N = size(uinput,2); tau = N; Barker_code = uinput; samp_num = size(Barker_code,2) *10; n = ceil(log(samp_num) / log(2)); nfft = 2^n; u(1:nfft) = 0; j = 0; for index = 1:10:samp_num index; j = j+1; u(index:index+10-1) = Barker_code(j); end v = u; delay = linspace(-tau, tau, nfft); freq_del = 12 / tau /100; j = 0; vfft = fft(v,nfft); for freq = -6/tau:freq_del:6/tau; j = j+1; exf = exp(sqrt(-1) * 2. * pi * freq .* delay); u_times_exf = u .* exf; ufft = fft(u_times_exf,nfft); prod = ufft .* conj(vfft); ambig(:,j) = fftshift(abs(ifft(prod))'); end freq = -6/tau:freq_del:6/tau; delay = linspace(-N,N,nfft); figure (1) mesh(freq,delay,ambig ./ max(max(ambig))) %colormap([.5 .5 .5]) %colormap(gray) axis tight xlabel('frequency') ylabel('delay') zlabel('ambiguity function') figure (2) value = 10 * N ; plot(delay,ambig(:,51)/value,'k') xlabel('delay') ylabel('normalized amibiguity cut for f=0') grid axis tight figure (3) contour(freq,delay,ambig ./ max(max(ambig))) %colormap([.5 .5 .5]) %colormap (gray) xlabel('frequency') ylabel('delay') grid on
test.m
close all clear all u = [1 1 1 1 1 -1 -1 1 1 -1 1 -1 1]; x = Barker_ambig(u);
程序中举例的是长度为 13 的巴克码
②、仿真结果
1)巴克码的模糊函数图
2)巴克码的模糊函数切面图
巴克码的零多普勒模糊函数图
3)巴克码的等高线图
7、伪随机数编码
伪随机数(PRN)编码也称为最大长度序列(MLS)码。
①、MATLAB 源码
prn_ambig.m
function [ambig] = prn_ambig(uinput) % Compute and plot the ambiguity function for a PRN code % Compute the ambiguity function by utilizing the FFT % through combining multiple range cuts N = size(uinput,2); tau = N; PRN = uinput; samp_num = size(PRN,2) * 10; n = ceil(log(samp_num) / log(2)); nfft = 2^n; u(1:nfft) = 0; j = 0; for index = 1:10:samp_num index; j = j+1; u(index:index+10-1) = PRN(j); end % set-up the array v v = u; delay = linspace(0,5*tau,nfft); freq_del = 8 / tau /100; j = 0; vfft = fft(v,nfft); for freq = -4/tau:freq_del:4/tau; j = j+1; exf = exp(sqrt(-1) * 2. * pi * freq .* delay); u_times_exf = u .* exf; ufft = fft(u_times_exf,nfft); prod = ufft .* conj(vfft); ambig(:,j) = fftshift(abs(ifft(prod))'); end freq = -4/tau:freq_del:4/tau; delay = linspace(-N,N,nfft); figure(1) mesh(freq,delay,ambig ./ max(max(ambig))) % colormap([.5 .5 .5]) % colormap(gray) axis tight xlabel('frequency') ylabel('delay') zlabel('ambiguity function a PRN code') figure(2) plot(delay,ambig(:,51)/(max(max(ambig))),'k') xlabel('delay') ylabel('normalized amibiguity cut for f=0') grid axis tight figure(3) contour(freq,delay,ambig ./ max(max(ambig))) axis tight % colormap([.5 .5 .5]) % colormap(gray) xlabel('frequency') ylabel('delay')
test.m
close all clear all u_31 = [1 -1 -1 -1 -1 1 -1 1 -1 1 1 1 -1 1 1 -1 -1 -1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 -1]; x = prn_ambig(u_31);
u_31 是一个向量,它定义了以 “1” 和 “-1” 表示的输入最大长度码(序列)
②、仿真结果
1)PRN 码的模糊函数图
2)PRN 码的模糊函数切面图
PRN 码的零多普勒模糊函数图
3)PRN 码的等高线图