MATLAB仿真程序.docx
《MATLAB仿真程序.docx》由会员分享,可在线阅读,更多相关《MATLAB仿真程序.docx(8页珍藏版)》请在冰点文库上搜索。
![MATLAB仿真程序.docx](https://file1.bingdoc.com/fileroot1/2023-7/17/32ed0270-fcd7-4594-8f58-80f53db1f3df/32ed0270-fcd7-4594-8f58-80f53db1f3df1.gif)
MATLAB仿真程序
窗型选择仿真程序:
clear,clc
bw=3e6;%信号带宽
T=1e-4;%信号脉冲宽度
A=2;%信号幅度
fs=4*bw;
lfft=round(T*fs);%采样点数
lfft=2^nextpow2(lfft);
dt=1/fs;%采样间隔
f0=1e6;
t=(0:
lfft-1)*dt;%时域采样点
q=(0:
lfft-1)*2*pi/lfft;
s=A*exp(j*2*pi*f0*t+j*pi*bw*t.*t/T);%产生线性调频信号
S=(fft(s));%线性调频信号的傅立叶变换fft
H=conj(S);%匹配滤波器的频率响应
Y=S.*H;%线性调频信号的频域匹配滤波输出
y=fftshift(ifft(Y));%线性调频信号的时域匹配滤波输出
%对chirp信号进行时域加权
h1=(triang(lfft))';%三角窗函数
s1=s.*h1;S1=fft(s1);H1=conj(S1);
Y1=S1.*H1;
y1=fftshift(ifft(Y1));%加三角窗后的线性调频信号的时域匹配滤波输出h2=(hanning(lfft))';%汉宁窗函数
s2=s.*h2;S2=fft(s2);H2=conj(S2);
Y2=S2.*H2;
y2=fftshift(ifft(Y2));%加汉宁窗后的线性调频信号的时域匹配滤波输出h3=(hamming(lfft))';%海明窗函数
s3=s.*h3;S3=fft(s3);H3=conj(S3);
Y3=S3.*H3;
y3=fftshift(ifft(Y3));%加海明窗后的线性调频信号的时域匹配滤波输出
figure;
subplot(3,1,1),
plot(t,real(s)),title('chirpsignal');
subplot(3,1,2),
plot(q,abs(S)),title('线性调频信号幅度谱');
subplot(3,1,3),
plot(q,angle(S)),title('线性调频信号相位谱');
figure;
subplot(2,1,1),plot(q,abs(H));title('MF的幅度谱');
subplot(2,1,2),plot(q,angle(H));title('MF的相位谱');
figure;
subplot(3,1,1),
plot(t,real(y)),title('脉压信号');
subplot(3,1,2),plot(q,abs(Y)),title('脉压信号幅度谱');
subplot(3,1,3),plot(q,angle(Y)),title('脉压信号相位谱');
figure;
subplot(2,2,1),
plot(t,20*log10(abs(y)/max(abs(y))));title('未加窗时的时域输出');subplot(2,2,2),
plot(t,20*log10(abs(y1)/max(abs(y1))));title('加三角窗时的时域输出');subplot(2,2,3),
plot(t,20*log10(abs(y2)/max(abs(y2))));title('加汉宁窗时的时域输出');subplot(2,2,4),
plot(t,20*log10(abs(y3)/max(abs(y3))));title('加海明窗时的时域输出');
叠加3个频移多普勒干扰程序:
BandWidth=10e6;%发射信号带宽
TimeWidth=20e-6;%发射信号时宽
mu=BandWidth/TimeWidth%调频率
Fs=2*BandWidth;%采样频率
Ts=1/Fs;
Ns=fix(Fs*TimeWidth);%计算一个脉冲周期的采样点数400;
N=1024;%FFT点数
t=0:
Ts:
TimeWidth-Ts;
y=exp(j*pi*mu*t.^2);%产生LFM信号
h=zeros(1,Ns);
fori=1:
Ns
h(i)=conj(y(Ns-i+1));
end
fd=6e6;
y1=exp(j*2*pi*(fd*t+0.5*mu*t.^2));%频移干扰信号
fd1=+1e6;
y2=exp(j*2*pi*(fd1*t+0.5*mu*t.^2));%频移干扰信
fd2=+10e6;
y3=exp(j*2*pi*(fd2*t+0.5*mu*t.^2));%频移干扰信
y=y1+exp(j*pi*mu*t.^2)+y2+y3;%产生叠加了干扰的LFM信号
yfft=fft(y,1024);
win=hamming(Ns)';
h_w=h.*win;
hfft_w=fft(h_w,1024);
ycomp=abs(ifft(yfft.*hfft_w));%脉冲压缩
maxval1=max(ycomp);
ycomp_w=eps+ycomp./maxval1;%利用ycomp的最大值归一化tt=0:
Ts:
2*TimeWidth-Ts;
plot(tt,ycomp_w(1:
2*Ns),'b')
xlabel('t-seconds');
ylabel('幅度db')
title('带宽=10MHZ,叠加fd=0MHZ,+1MHZ,+6MHZ,+10MHZ的脉压')gridon
加噪仿真:
BandWidth=1.0e6;%发射信号带宽
TimeWidth=200e-6;%发射信号时宽
mu=BandWidth/TimeWidth%调频率
Fs=2*BandWidth;%采样频率
Ts=1/Fs;
Ns=fix(Fs*TimeWidth);%计算一个脉冲周期的采样点数400;
N=1024;%FFT点数
t=0:
Ts:
TimeWidth-Ts;
%====================================================================y=exp(j*pi*mu*t.^2);%产生LFM信号
figure
(1)
plot(real(y));%加噪前的输入信号
title('未加噪前的LFM信号');
h=zeros(1,Ns);
fori=1:
Ns
h(i)=conj(y(Ns-i+1));
end
figure
(2)
plot(real(h));
title('匹配滤波器信号');
hfft=fft(h,N);%匹配滤波器的频域响应
y_n=awgn(y,20);%在中叠加一个信噪比为20的高斯白噪声
figure(3)
plot(real(y_n));%加噪后的输入信号
title('加噪后的LFM信号');
y_nfft=fft(y_n,N);
ycomp=abs(ifft(y_nfft.*hfft));%脉冲压缩
maxval=max(ycomp);
ycomp=eps+ycomp./maxval;%利用最大值归一化
ycomp_db=20*log10(ycomp);%取对数
%%%%%%%%%%%%%%加窗处理%%%%%%%
win=hamming(Ns)';
figure(4)
plot(win);
title('海明窗信号');
h_w=h.*win;%加窗
hfft_w=fft(h_w,N);%加窗的匹配滤波器的频域响应
ycomp_w=abs(ifft(y_nfft.*hfft_w));%脉冲压缩
maxval1=max(ycomp_w);
val=ycomp_w;
ycomp_w=eps+ycomp_w./maxval;%利用ycomp的最大值归一化ycomp_w1=eps+val./maxval1;%利用ycomp_w的最大值归一化ycomp_w_db=20*log10(ycomp_w);%取对数
ycomp_w1_db=20*log10(ycomp_w1);%取对数%%%%%%%%%%%%%%%%
tt=0:
Ts:
2*TimeWidth-Ts;
figure(5)
plot(tt,ycomp_db(1:
2*Ns),'b')
axis([.2*TimeWidth1.8*TimeWidth-600])
xlabel('t-seconds');
ylabel('幅度db')
title('未加窗的脉冲压缩输出')
gridon
figure(6)
plot(tt,ycomp_w1_db(1:
2*Ns),'r')
axis([.2*TimeWidth1.8*TimeWidth-600])
xlabel('t-seconds');
ylabel('幅度db')
title('加窗的脉冲压缩输出')
gridon
figure(7)
plot(tt,ycomp_db(1:
2*Ns),'b',tt,ycomp_w_db(1:
2*Ns),'r')
axis([.2*TimeWidth1.8*TimeWidth-600])
xlabel('t-seconds');
ylabel('幅度db')
legend('未加窗','加窗');
title('脉冲压缩输出对比')
gridon
延时干扰仿真:
BandWidth=1.0e6;%发射信号带宽
TimeWidth=200e-6;%发射信号时宽
mu=BandWidth/TimeWidth%LFM的调频率
Fs=2*BandWidth;%采样频率
Ts=1/Fs;%采样周期
Ns=fix(Fs*TimeWidth);%计算一个脉冲周期的采样点数;
N=1024;%FFT点数
t=0:
Ts:
TimeWidth-Ts;
y=exp(j*pi*mu*t.^2);%产生LFM信号,写成复数的形式
h=zeros(1,Ns);%匹配系数初始化为0,点数与LFM的点数一致
fori=1:
Ns
h(i)=conj(y(Ns-i+1));
end%匹配滤波系数取LFM信号的镜像共轭
yfft=fft(y,1024);%对回波LFM信号做FFT变换
win=hamming(Ns)';%产生海明窗
h_w=h.*win;%时域加海明窗,匹配系数乘以海明窗函数,完成加权抑制距离旁瓣hfft_w=fft(h_w,1024);%加权后的匹配系数做FFT变换
ycomp=abs(ifft(yfft.*hfft_w));%完成脉冲压缩
maxval1=max(ycomp);%取ycomp的最大值
ycomp_w=ycomp./maxval1;%利用ycomp的最大值归一化
tt=0:
Ts:
2*TimeWidth-Ts;
subplot(2,1,1);
plot(tt,ycomp_w(1:
2*Ns),'b')
axis([.2*TimeWidth1.8*TimeWidth01])%设定显示图形的尺寸
title('时宽=200us无时延的脉冲压缩输出');
gridon;
td1=20e-6;%时延值为td1
t1=t+td1;%有时延的时间变量
yd1=exp(j*pi*mu*t1.^2);%产生时延为td1的LFM信号
td2=20e-6%时延值为td2
t2=t-td2;
yd2=exp(j*pi*mu*t2.^2);%产生时延为td2的LFM信号
y1=y+yd1+yd2;%叠加有2个时延的回波信号
y1fft=fft(y1,1024);
hfft_w=fft(h_w,1024);
ycomp_w1=abs(ifft(y1fft.*hfft_w));%脉冲压缩
maxval1=max(ycomp_w1);
ycomp_w2=ycomp_w1./maxval1;%利用ycomp_w1的最大值归一化%%%%%%%%%%%%%%%%
tt=0:
Ts:
2*TimeWidth-Ts;
subplot(2,1,2);
plot(tt,ycomp_w2(1:
2*Ns),'r')
axis([.1*TimeWidth2.0*TimeWidth01])xlabel('t-seconds');
title('有td=+20us,-20us时延干扰输出')gridon