# 雷达模糊函数及MATLAB仿真（三）

### 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);

### 7、伪随机数编码

#### ①、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” 表示的输入最大长度码（序列）

PRN 码的零多普勒模糊函数图

## 三、资源自取

|
7天前
|

m基于Q-Learning强化学习的路线规划和避障策略matlab仿真
MATLAB 2022a仿真实现了Q-Learning算法在路线规划与避障中的应用，展示了智能体在动态环境中学习最优路径的过程。Q-Learning通过学习动作价值函数Q(s,a)来最大化长期奖励，状态s和动作a分别代表智能体的位置和移动方向。核心程序包括迭代选择最优动作、更新Q矩阵及奖励机制（正奖励鼓励向目标移动，负奖励避开障碍，探索奖励平衡探索与利用）。最终，智能体能在复杂环境中找到安全高效的路径，体现了强化学习在自主导航的潜力。
12 0
|
1天前
|

16 5
|
2天前
|

14 1
|
5天前
|

m基于BP译码算法的LDPC编译码matlab误码率仿真,对比不同的码长
MATLAB 2022a仿真实现了LDPC码的性能分析，展示了不同码长对纠错能力的影响。短码长LDPC码收敛快但纠错能力有限，长码长则提供更强纠错能力但易陷入局部最优。核心代码通过循环进行误码率仿真，根据EsN0计算误比特率，并保存不同码长（12-768）的结果数据。
26 9
|
8天前
|

17 4
|
8天前
|

18 0
|
8天前
|

18 1
|
8天前

44 1
|
8天前
|

31 0
|
8天前
|

20 1