matlab仿真代碼(見最后):
勘誤
rect?(tT)={1∣t/T∣<0.50elsewise?\operatorname{rect}\left(\displaystyle \frac{t}{T}\right)=\left\{\begin{array}{ll}1 & \left| t/T\right|<0.5 \\ 0 & \text { elsewise }\end{array}\right.rect(Tt?)={10?∣t/T∣<0.5?elsewise??
代碼:
close all;clear all;clcC = 3e8; % 光速
fc = 2.7619e6; % 中心頻率 fc = 20/N*Fs=2.7619e6;
T = 7.24e-6; % 信號持續時間
B = 5.8e6; % 信號帶寬
K = B/T; % 調頻率
ratio = 5; % 過采樣率
Fs = ratio*B; % 采樣頻率
dt = 1/Fs; % 采樣間隔
N = ceil(T/dt); % 采樣點數
t = ((0:N-1)-N/2)/N*T; % 時間軸
f = ((0:N-1)-N/2)/N*Fs; % 頻率軸
st1 = exp(1i*2*pi*(fc*t+1/2*K*t.^2)); % 生成信號
st2 = exp(1i*pi*K*t.^2); % 生成信號figure,set(gcf,'Color','w');
subplot(2,2,1),plot(t*1e6,real(st1));
title('(a)信號的實部'),xlabel('相對于t_{0}時間(\mus)'),ylabel('幅度');
subplot(2,2,2),plot(t*1e6,fc*t+pi*K*t.^2);
title('(c)信號的相位'),xlabel('相對于t_{0}時間(\mus)'),ylabel('弧度');
subplot(2,2,3),plot(t*1e6,imag(st1));
title('(b)信號的虛部'),xlabel('相對于t_{0}時間(\mus)'),ylabel('幅度');
subplot(2,2,4),plot(t*1e6,(fc+K*t)*1e-6);
title('(d)信號頻率'),xlabel('相對于t_{0}時間(\mus)'),ylabel('MHz');%% 中心頻率對頻譜的影響
sf1 = fftshift(fft(st1,[],2),2); % 對st1做傅里葉變換并將零頻搬移至中心
sf2 = fftshift(fft(st2,[],2),2);figure,set(gcf,'Color','w');
subplot(2,2,1),plot(f*1e-6,abs(sf1));
line([fc*1e-6,fc*1e-6],[0 40],'linestyle','--','Color','r', 'LineWidth', 1);
text(fc*1e-6,-2,'fc')
title('(a)幅頻特性:中心頻率為f_{c}'),xlabel('頻率(MHz)'),ylabel('幅度');
subplot(2,2,2),plot(f*1e-6,angle(sf1));
line([fc*1e-6,fc*1e-6],[-5 5],'linestyle','--','Color','r', 'LineWidth', 1);
title('(a)相頻特性:中心頻率為f_{c}'),xlabel('頻率(MHz)'),ylabel('相位');
subplot(2,2,3),plot(f*1e-6,abs(sf2));
line([0,0],[0 40],'linestyle','--','Color','r', 'LineWidth', 1);
title('(a)幅頻特性:中心頻率為0'),xlabel('頻率(MHz)'),ylabel('幅度');
subplot(2,2,4),plot(f*1e-6,angle(sf2));
line([0,0],[-5 5],'linestyle','--','Color','r', 'LineWidth', 1);
title('(a)相頻特性:中心頻率為0'),xlabel('頻率(MHz)'),ylabel('相位');%% 時移對頻譜的影響
tau =2500/N*T; % 時延tau=3.4476 us
fc_tau = fc-K*tau+(ceil((fc-K*tau)/(-Fs)-1/2))*Fs; % 時延后的中心頻率st3 = exp(1i*2*pi*(fc*t+1/2*K*t.^2)); % 原始信號
st4 = exp(1i*2*pi*(fc*(t-tau)+1/2*K*(t-tau).^2)); % 時延信號sf3 = fftshift(fft(st3,[],2),2);
sf4 = fftshift(fft(st4,[],2),2);figure,set(gcf,'Color','w');
subplot(2,2,1),plot(f*1e-6,abs(sf3));
line([fc*1e-6,fc*1e-6],[0 40],'linestyle','--','Color','r', 'LineWidth', 1);
text(fc*1e-6,-2,'fc')
title('(a)幅頻特性:原始信號'),xlabel('頻率(MHz)'),ylabel('幅度');
subplot(2,2,2),plot(f*1e-6,angle(sf3));
line([fc*1e-6,fc*1e-6],[-5 5],'linestyle','--','Color','r', 'LineWidth', 1);
title('(a)相頻特性:原始信號'),xlabel('頻率(MHz)'),ylabel('相位');
subplot(2,2,3),plot(f*1e-6,abs(sf4));
line([fc_tau*1e-6,fc_tau*1e-6],[0 40],'linestyle','--','Color','r', 'LineWidth', 1);
title('(a)幅頻特性:時延信號'),xlabel('頻率(MHz)'),ylabel('幅度');
subplot(2,2,4),plot(f*1e-6,angle(sf4));
line([(fc_tau)*1e-6,fc_tau*1e-6],[-5 5],'linestyle','--','Color','r', 'LineWidth', 1);
title('(a)相頻特性:時延信號'),xlabel('頻率(MHz)'),ylabel('相位');%% 解調對頻譜的影響 tau =2500/N*T; % 時延tau=3.4476 us
fc_tau = fc-K*tau+(ceil((fc-K*tau)/(-Fs)-1/2))*Fs; % 時延后的中心頻率
fc_jt = -K*tau+(ceil((-K*tau)/(-Fs)-1/2))*Fs; % 時延后的中心頻率st5 = exp(1i*2*pi*(fc*(t-tau)+1/2*K*(t-tau).^2)); % 原始信號
st6 = exp(1i*2*pi*(fc*(-tau)+1/2*K*(t-tau).^2)); % 解調后信號sf5 = fftshift(fft(st5,[],2),2);
sf6 = fftshift(fft(st6,[],2),2);figure,set(gcf,'Color','w');
subplot(2,2,1),plot(f*1e-6,abs(sf5));
line([fc_tau*1e-6,fc_tau*1e-6],[0 40],'linestyle','--','Color','r', 'LineWidth', 1);
text(fc*1e-6,-2,'fc')
title('(a)幅頻特性:原始信號'),xlabel('頻率(MHz)'),ylabel('幅度');
subplot(2,2,2),plot(f*1e-6,angle(sf5));
line([fc_tau*1e-6,fc_tau*1e-6],[-5 5],'linestyle','--','Color','r', 'LineWidth', 1);
title('(a)相頻特性:原始信號'),xlabel('頻率(MHz)'),ylabel('相位');
subplot(2,2,3),plot(f*1e-6,abs(sf6));
line([fc_jt*1e-6,fc_jt*1e-6],[0 40],'linestyle','--','Color','r', 'LineWidth', 1);
title('(a)幅頻特性:解調后信號'),xlabel('頻率(MHz)'),ylabel('幅度');
subplot(2,2,4),plot(f*1e-6,angle(sf6));
line([(fc_jt)*1e-6,fc_jt*1e-6],[-5 5],'linestyle','--','Color','r', 'LineWidth', 1);
title('(a)相頻特性:解調后信號'),xlabel('頻率(MHz)'),ylabel('相位');%% 脈沖壓縮 -- 匹配濾波
tau =150/N*T;
st7 = exp(1i*2*pi*(fc*(t-tau)+1/2*K*(t-tau).^2)); % 基本信號
st8 = [zeros(1,N/2),st7,zeros(1,N/2)]; % 補零信號
Nfft = 2*N;
f_h = ((0:Nfft-1)-Nfft/2)/Nfft*Fs;Sf = fftshift(fft(st8,[],2),2); % 實際信號的傅里葉變換
Hf1 = fftshift(fft(conj(fliplr(st7)),Nfft,2),2); % 方式1的匹配濾波器
Hf2 = fftshift(conj(fft(st7,Nfft,2)),2); % 方式2的匹配濾波器
Hf3 = exp(1i*pi*f_h.^2/K); % 方式3的匹配濾波器S1 = ifft(ifftshift(Sf.*Hf1,2),[],2);
S2 = ifft(ifftshift(Sf.*Hf2,2),[],2);
S3 = ifft(ifftshift(Sf.*Hf3,2),[],2);figure,set(gcf,'Color','w');
subplot(2,2,1),plot(real(st8));
title('原始信號'),xlabel('采樣點'),ylabel('實部');
subplot(2,2,2),plot(abs(S1));
title('方式1匹配濾波'),xlabel('采樣點'),ylabel('幅度');
subplot(2,2,3),plot(abs(S2));
title('方式2匹配濾波'),xlabel('采樣點'),ylabel('幅度');
subplot(2,2,4),plot(abs(S3));
title('方式3匹配濾波'),xlabel('采樣點'),ylabel('幅度');%% 脈沖壓縮--解線性調頻
tau =100/N*T; % 目標1信號時延
tref =130/N*T; % 參考信號時延(目標1)
fdc1 = -K*(tau-tref);
fdc2 = 0;
st9 = (abs(t-tau)<T/2).*exp(1i*2*pi*(fc*(t-tau)+1/2*K*(t-tau).^2)); % 目標1信號
st10 = exp(1i*2*pi*(fc*(t-tref)+1/2*K*(t-tref).^2)); % 參考信號
st11 = st9.*conj(st10); % 目標1差頻
st12 = st10.*conj(st10); % 參考目標差頻
Sd1 = fftshift(fft(st11,[],2),2); % 目標1差頻頻譜
Sd2 = fftshift(fft(st12,[],2),2); % 參考目標差頻頻譜
Hrvp = exp(-1i*pi/K*f.^2); % 去斜濾波器
Sdc1 = Sd1.*Hrvp; % 去斜
Sdc2 = Sd2.*Hrvp; % 去斜
figure,set(gcf,'Color','w');
subplot(2,2,1),plot(f*1e-6,abs(Sd1));
line([fdc1*1e-6,fdc1*1e-6],[0 120],'linestyle','--','Color','r', 'LineWidth', 1)
title('目標1解調'),xlabel('頻率(MHz)'),ylabel('幅度');
subplot(2,2,3),plot(f*1e-6,abs(Sdc1));
line([fdc1*1e-6,fdc1*1e-6],[0 120],'linestyle','--','Color','r', 'LineWidth', 1)
title('目標1去斜'),xlabel('頻率(MHz)'),ylabel('幅度');
subplot(2,2,2),plot(f*1e-6,abs(Sd2));
line([fdc2*1e-6,fdc2*1e-6],[0 250],'linestyle','--','Color','r', 'LineWidth', 1)
title('參考目標解調'),xlabel('頻率(MHz)'),ylabel('幅度');
subplot(2,2,4),plot(f*1e-6,abs(Sdc2));
line([fdc2*1e-6,fdc2*1e-6],[0 250],'linestyle','--','Color','r', 'LineWidth', 1)
title('參考目標去斜'),xlabel('頻率(MHz)'),ylabel('幅度');% 多目標混頻輸出
tau1 =100/N*T; % 目標1信號時延
tau2 =160/N*T; % 目標2信號時延
fdc1 = -K*(tau1-tref);
fdc2 = -K*(tau2-tref);st13 = (abs(t-tau)<T/2).*exp(1i*2*pi*(fc*(t-tau1)+1/2*K*(t-tau1).^2));
st14 = (abs(t-tau)<T/2).*exp(1i*2*pi*(fc*(t-tau2)+1/2*K*(t-tau2).^2));
st15 = st13+st14;
st16 = st15.*conj(st10);
sf17 = fftshift(fft(st16,[],2),2);
sf18 = sf17.*Hrvp;
figure,set(gcf,'Color','w');
plot(f*1e-6,abs(sf18));
line([fdc1*1e-6,fdc1*1e-6],[0 150],'linestyle','--','Color','r', 'LineWidth', 1)
line([fdc2*1e-6,fdc2*1e-6],[0 150],'linestyle','--','Color','r', 'LineWidth', 1)
title('混頻信號脈壓'),xlabel('頻率(MHz)'),ylabel('幅度');
總結
以上是生活随笔為你收集整理的线性调频信号学习笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。