
% Adam Wang, 17 Mar 2008
% Example use of st1d.m, as described in PSYCH 221 Project Report

t = 0:127;
h(1:64) = cos(2*pi*t(1:64)*6/128);
h(65:128) = cos(2*pi*t(65:128)*25/128);
h(21:31) = h(21:31) + .5*cos(2*pi*t(21:31)*52/128);

S1 = st1d(h);

figure, plot(t,h);
xlabel('Time (s)');
ylabel('Intensity');
axis([0 128 -2 2]);

freq = (.5:-.5/64:0)'*ones(1,128); time = ones(65,1)*t;
figure, colormap gray; contourf(time,freq,abs(S1(1:65,:)),[0 .1:.05:.5]);
xlabel('Time (s)');
ylabel('Frequency (Hz)');
title('Stockwell Transform');



S2 = zeros(128,128);
for i = 1:1000
    white = randn(1,128);
    S2 = S2 + abs(st1d(white));
end
S2 = S2/1000;

figure, plot(t,white,[-3 3]);
xlabel('Time (s)'); ylabel('Intensity'); title('Single Realization of White Noise');

freq = (.5:-.5/64:0)'*ones(1,128); time = ones(65,1)*t;
figure, colormap gray; contourf(time,freq,abs(S2(1:65,:)),[0 .1:.05:.5]);
xlabel('Time (s)');
ylabel('Frequency (Hz)');
title('Stockwell Transform');

