clc;clear all;
f0=100;%单频信号频率
fs=400;%采样率
T=2;%脉冲时间
ts=3;%信号持续时间
t=0:1/fs:T-1/fs;%单频信号的时间
time=0:1/fs:ts-1/fs;%cw信号的时间
st=[exp(1j*2*pi*f0*t),zeros(1,length(time)-length(t))];%cw信号
dk=0.1;%频偏的增量
kexi=-15:dk:15-dk;%频偏的范围
tao=-ts:1/fs:ts-2*1/fs;%时延的范围
for a=1:length(kexi)
stao=st.*exp(1j*2*pi*kexi(a)*time);%频偏后的信号
x(a,:)=xcorr(st,stao);%对原始信号跟频偏后的信号作相关
end
figure;
surf(tao,kexi,abs(x));axis([-3,3,-15,15,0,800]);xlabel('时延');ylabel('频偏');shading interp;%模糊图
figure;
v=[0.707*max(max(abs(x))),0.707*max(max(abs(x)))];
contour(tao,kexi,abs(x),v,'ShowText','on');grid on;%模糊度 引用链接:https://blog.csdn.net/weixin_44586750/article/details/105250539