|
close all
clear
clc
Fs = 10*10^3; % 采样频率
Ts = 1/Fs; % 采样周期
Fh = 20; % 跳频频率
Th = 1/Fh; % 跳频周期
SNR = 20; % 信噪比
snr = 10^(SNR/10); % 线性信噪比
f_set = [5 15 10 30 32 20 15 30 45 35 40 44]*10^2; % 跳频频率集
noise_f = 24*10^2; %定频干扰频率
N = length(f_set); % 跳频点数
t = 0:1/Fs:N*Th-1/Fs; % 时间
% 产生跳频信号,每个跳频周期对就一个频率
% 每个跳频周期的时间点为Th/Ts
for i = 1:N
sig(1+(i-1)*fix(Th/Ts):i*fix(Th/Ts)) = sqrt(2)*cos(2*pi*f_set(i)*t(1+(i-1)*fix(Th/Ts):i*fix(Th/Ts)));
noise_sig(1+(i-1)*fix(Th/Ts):i*fix(Th/Ts)) = sqrt(2)*cos(2*pi*noise_f*t(1+(i-1)*fix(Th/Ts):i*fix(Th/Ts)));%定频干扰
end
x = sig + noise_sig ;%加定频干扰
figure
subplot(211);
plot(t,x);
xlabel('时间 t/s');
ylabel('幅度');
title('跳频信号');
grid on;
subplot(212);
L = length(x);
NFFT = 2^nextpow2(L);
Y = abs(fft(x,NFFT));
f = (0:length(Y)-1)*Fs/length(Y);
plot(f(1:NFFT/2), 2*Y(1:NFFT/2));
xlabel('频率 f/Hz');
ylabel('|Y(f)|');
title('跳频信号频谱');
grid on;
x = x';
x = hilbert(x);
N = 2^nextpow2(length(x));
H = window(@hamming,1023);
[TFR,T,F]=tfrstft(x,1:length(x),N,H);
figure
contour(t,F(1:N/2),abs(TFR(1:N/2,: )));
axis([min(t), max(t), 0, 0.5])
ylabel('归一化频率 f/Hz');
xlabel('时间 t/s');
title('STFT变换时频图');
colormap
grid on;
f = F(1:N/2);
SQTFR = abs(TFR(1:N/2,: )).^2;
ff = sum(repmat(f,1,size(SQTFR,2)).*SQTFR,1)./sum(SQTFR,1);
figure
plot(t,ff)
xlabel('时间 t/ms');
ylabel('归一化频率 f/Hz');
title('时频重心曲线')
wf = wden(ff,'sqtwolog','s','mln',3,'haar');
figure
plot(t,wf)
xlabel('时间 t/ms');
ylabel('模值');
title('小波变换结果')
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|