www.pudn.com > tfGabor.rar > tfGabor.m


%小波Gabor变换的实现程序 
clf; 
clear all ; 
close all;  
fs=100;    %采样率 
Ts=1/fs;    
t=0:Ts:10;   
gass=2^(1/4)*exp(-pi*(t).^2).*cos(5*pi*t);   % 生成一个高斯函数 
subplot(221),plot(t,gass); 
title('高斯函数'); 
xlabel('t'); 
ylabel('幅度'); 
T=0:Ts:10; 
ft=cos(T.^2+2*T)+cos(T.^2);  % 生成要变换的信号函数 
subplot(222),plot(t,ft);   
title('信号函数'); 
xlabel('time'); 
ylabel('幅度'); 
y=fft(ft);       %信号做FFT变换 
amp=abs(y); 
subplot(223);plot(amp); 
title('信号的FFT变换'); 
xlabel('F(Hz)'); 
ylabel('幅度'); 
subplot(224),plot(t,imag(hilbert(ft))); 
 
 
shl=100;           %高斯窗每次平移点数 
shn=(length(t)-1)/shl;    %求高斯窗平移总次数 
y2=zeros(shn,2001); 
for k=0:shn-1; 
    gassc=2^(1/4)*exp(-pi*(t-k*shl*Ts).^2).*cos(5*pi*t);    %平移后的高斯函数 
    gassc2=gassc/sum(gassc.^2)                           %归一化 
    yl=conv(hilbert(ft),gassc2);                         %短时傅立叶变换,即对信号与Gauss函数做卷积 
    y2(k+1,:)=yl; 
end 
 
% 最后的图形显示 
[F,T]=size(y2); 
[F,T]=meshgrid(1:T,1:F); 
figure(2),mesh(F,T,abs(y2)) 
title('信号 a-F图'); 
xlabel('F(Hz)'); 
ylabel('尺度') 
zlabel('幅度'); 
figure(3),contour(F,T,abs(y2))    % 等高线图 
 
% Dinga's Blog http://www.dinga.cn +++++++