
% Adam Wang, 17 Mar 2008
% 1D Stockwell Transform

function S = st1d(h)
%
% S = st1d(h)
%
% h is a column vector
%
% st1d performs a 1D Stockwell Transform
%
N = length(h);
S = zeros(N,N);
H = fft(h); % using the notation and algorithm from IEEE Trans Sig Proc, Localization of Complex Spectrum, Stockwell 1996, pg 999

m = [0:floor(N/2) -(ceil(N/2)-1):-1];
n = [-(ceil(N/2)-1):-1 1:floor(N/2)];

for i = 1:N-1
    
    G = exp(-2*pi^2*m.^2/n(i)^2); 
    S(floor(N/2)+1-n(i),:) = ifft(G.*circshift(H,[0 -n(i)]));
    
end

S(floor(N/2)+1,:) = sum(h)/N;
% S = flipud(fftshift(S,1));

