声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1272|回复: 0

[综合] 时频分析出错了,请大神帮帮忙指导一下

[复制链接]
发表于 2015-1-27 10:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
%%跳频信号产生
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,[0:M-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
%[tfr_STFT,t,f]=tfrstft(sig,1:8192,8192,w);
   

        %---------- FSK调制 ---------------------
        [s_fsk,t]=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=[1000 1200 1400 1600]; % 跳频频率 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=[1 3 2 3 2 4 1 4 1 3 2 3 2 4 1 4 1 3 2 3 2 4 1 4 1 3 2 3 2 4 1 4 1 3 2 3 2 4 1 4]; %跳频序列周期为 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,[Fh(1)-30,Fh(1)+30]/Fs);%带通滤波
                    s_mix_fir=filter(cof_passband,1,s_mix);
                    s_hop=[s_hop s_mix'];
                case(2)
                    s_mix=s_fir((FsFd/2*(i-1)+1):(FsFd/2*i)).*carrier2';
                    cof_passband=fir1(64,[Fh(2)-30,Fh(2)+30]/Fs);
                    s_mix_fir=filter(cof_passband,1,s_mix);
                    s_hop=[s_hop s_mix'];
               case(3)
                    s_mix=s_fir((FsFd/2*(i-1)+1):(FsFd/2*i)).*carrier3';
                    cof_passband=fir1(64,[Fh(3)-30,Fh(3)+30]/Fs);
                    s_mix_fir=filter(cof_passband,1,s_mix);
                    s_hop=[s_hop s_mix'];
               case(4)
                   s_mix=s_fir((FsFd/2*(i-1)+1):(FsFd/2*i)).*carrier4';
                   cof_passband=fir1(64,[Fh(4)-30,Fh(4)+30]/Fs);
                   s_mix_fir=filter(cof_passband,1,s_mix);
                   s_hop=[s_hop s_mix'];
            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([1 2048 -1.2 1.2]);
% %计算短时傅立叶变换
w = window(@gausswin,127,0.05); %高斯窗,sigma = 0.05
[tfr_STFT,t,f]=tfrstft(sig,1:8192,8192,w);
% %时频表示
figure;
contour(t,f,abs(tfr_STFT));
xlabel('时间 t');
ylabel('频率 f');
% %
%计算Wigner-Ville分布
[tfr_WVD,t,f]=tfrwv(sig,1:8192,512);
%时频表示
figure;
contour(t,f,abs(tfr_WVD));
xlabel('时间 t');
ylabel('频率 f');
%
% %计算伪Margenau-Hill分布
[tfr_MH,t,f]=tfrpmh(sig,1:8192,512);
figure;
contour(t,f,abs(tfr_MH));
xlabel('时间 t');
ylabel('频率 f');

% %计算Choi-Williams分布
[tfr_CW,t,f]=tfrcw(sig,1:8192,512);
figure;
contour(t,f,abs(tfr_CW));
xlabel('时间 t');
ylabel('频率 f');
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-3 14:03 , Processed in 0.051411 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表