在matlab中计算S变换及其平方值

时间:2015-05-13 05:05:16

标签: matlab wavelet time-frequency

让我们考虑以下代码来自

http://www.mathworks.com/matlabcentral/fileexchange/45848-stockwell-transform--s-transform-/content/stran.m

计算S变换,这是我的代码

Location:

并考虑以下啁啾信号

function ST=stran(h)
% Compute S-Transform without for loops
%%% Coded by Kalyan S. Dash %%%
%%% IIT Bhubaneswar, India %%%
[~,N]=size(h); % h is a 1xN one-dimensional series
nhaf=fix(N/2);
odvn=1;
if nhaf*2==N;
    odvn=0;
end
f=[0:nhaf -nhaf+1-odvn:-1]/N;
Hft=fft(h);
%Compute all frequency domain Gaussians as one matrix
invfk=[1./f(2:nhaf+1)]';
W=2*pi*repmat(f,nhaf,1).*repmat(invfk,1,N);
G=exp((-W.^2)/2); %Gaussian in freq domain
% End of frequency domain Gaussian computation
% Compute Toeplitz matrix with the shifted fft(h)
HW=toeplitz(Hft(1:nhaf+1)',Hft);
% Exclude the first row, corresponding to zero frequency
HW=[HW(2:nhaf+1,:)];
% Compute Stockwell Transform
ST=ifft(HW.*G,[],2); %Compute voice
%Add the zero freq row
st0=mean(h)*ones(1,N);

ST=[st0;ST];

end

我需要确认我正确地遵循了一些事情

>> t = 0:0.001:2;
x = chirp(t,100,1,200,'quadratic');

图片在这里 enter image description here

1 个答案:

答案 0 :(得分:1)

发表评论作为回答:

我对s变换并不太了解,但AFAIK的结果是3D信号(你可以清楚地看到ST的大小),所以你可能想做imagesc(abs(ST))surf(abs(ST),'linestyle','none')而不是情节。

在你的图中你绘制了1000行,这就是它如此混乱的原因。

使用

imagesc(abs(ST)) enter image description here