时频分析出错了,请大神帮帮忙指导一下
%%跳频信号产生clear all
clc
close all
Fd=20; %码元速率 20KHz
FsFd=600; %每符号采样点数 Fs/Fd
Fs=Fd*FsFd; %系统采样率 12MHz
f0=20; %空号频率 "0" 20KHz
f1=40; %传号频率 "1" 40KHz
Fc=(f0+f1)/2; %载频 30KHz
tone=f1-f0; %载波频率间隔 20KHz
M=2; %进制数
n0=20; %仿真符号数
db=1;
len_db=length(db);
time=50;
bits=randsrc(n0,1,);%产生20个二进制随机码
%%%出错了??? Error using ==> fft
%Out of memory. Type HELP MEMORY for your options.
%Error in ==> tfrstft at 78
%tfr=fft(tfr);
%Error in ==> tpfx at 35
%=tfrstft(sig,1:8192,8192,w);
%---------- FSK调制 ---------------------
=dmod(bits,Fc,Fd,Fs,'fsk',M,tone);
% s_fsk=fskmod(bits,M,tone,n0,Fs)
%--------- FSK调制后,低通滤波 --------------
cof_low=fir1(64,60/Fs);
s_fir=filter(cof_low,1,s_fsk);
%figure(3)
%plot(td,s_fir)
%title('FSK信号经过低通滤波的波形')
%xlabel('Symbols'),ylabel('s_{FIR}')
%ylim([-1.1 1.1])
%--------- 跳频信号产生 ---------------
Rh=2*Fd; % 跳频速率 40000 hops/s, 2跳/符号
hopNum=4; % 跳频点数 4
Fh=; % 跳频频率 KHz
k=linspace(0,1/n0/2,1/n0/2*Fs);%在0到1/40之间产生300点
carrier1=cos(2*pi*Fh(1)*k); % 产生扩频载波
carrier2=cos(2*pi*Fh(2)*k);
carrier3=cos(2*pi*Fh(3)*k);
carrier4=cos(2*pi*Fh(4)*k);
hop_sequence=; %跳频序列周期为 8
s_hop=[];
for i=1:2*n0 %n0是仿真符号数
switch(hop_sequence(i))
case(1)
s_mix=s_fir((FsFd/2*(i-1)+1):(FsFd/2*i)).*carrier1';
cof_passband=fir1(64,/Fs);%带通滤波
s_mix_fir=filter(cof_passband,1,s_mix);
s_hop=;
case(2)
s_mix=s_fir((FsFd/2*(i-1)+1):(FsFd/2*i)).*carrier2';
cof_passband=fir1(64,/Fs);
s_mix_fir=filter(cof_passband,1,s_mix);
s_hop=;
case(3)
s_mix=s_fir((FsFd/2*(i-1)+1):(FsFd/2*i)).*carrier3';
cof_passband=fir1(64,/Fs);
s_mix_fir=filter(cof_passband,1,s_mix);
s_hop=;
case(4)
s_mix=s_fir((FsFd/2*(i-1)+1):(FsFd/2*i)).*carrier4';
cof_passband=fir1(64,/Fs);
s_mix_fir=filter(cof_passband,1,s_mix);
s_hop=;
end
end
%size(s_hop)
%------------- 跳频信号及频谱观察 ----------------
%----------- AWGN信道模拟 -----------
snr=10^(db/10);
noise_power=100/(2*snr);
noise_std=sqrt(noise_power);
noise=noise_std*randn(1,12000);
s_mix=s_hop+noise;
%%跳频信号分析
sig=s_mix(1:8192)';
figure;plot(1:length(sig),real(sig));
% axis();
% %计算短时傅立叶变换
w = window(@gausswin,127,0.05); %高斯窗,sigma = 0.05
=tfrstft(sig,1:8192,8192,w);
% %时频表示
figure;
contour(t,f,abs(tfr_STFT));
xlabel('时间 t');
ylabel('频率 f');
% %
%计算Wigner-Ville分布
=tfrwv(sig,1:8192,512);
%时频表示
figure;
contour(t,f,abs(tfr_WVD));
xlabel('时间 t');
ylabel('频率 f');
%
% %计算伪Margenau-Hill分布
=tfrpmh(sig,1:8192,512);
figure;
contour(t,f,abs(tfr_MH));
xlabel('时间 t');
ylabel('频率 f');
% %计算Choi-Williams分布
=tfrcw(sig,1:8192,512);
figure;
contour(t,f,abs(tfr_CW));
xlabel('时间 t');
ylabel('频率 f');
页:
[1]