[x fs] = wavread('hw2-vocals.wav');
x = x(1:2*fs);
soundsc(x, fs)
length(x)

ans =

       40000

x = x(1:10*fs);
??? Index exceeds matrix dimensions.



[x fs] = wavread('hw2-vocals.wav');
x = x(1:10*fs);
g = rand(1, 1*fs);
tic; filter(g, 1, x); toc
Elapsed time is 7.394517 seconds.
tic; yf = filter(g, 1, x); toc
Elapsed time is 7.376605 seconds.
tic; yfast = fftfilt(g, x, 256); toc
Elapsed time is 0.469847 seconds.
max(abs(yf - yfast))

ans =

   2.3448e-13

plot(yf)
plot(x(3*fs+[1:256]))
plot(x(1*fs+[1:256]))
plot(x(3.5*fs+[1:256]))
y1 = x(3.5*fs+[1:256]);
y2 = x(3.5*fs+50+[1:256]);
subplot(211); plot(y1); subplot(212); plot(y2)
figure(2)
plot(xcorr(y1, y2))
plot(conv(y1, y2(end:-1:1)))
plot(conv(y1, y2(end:-1:1)))

figure(3)
n = rand(1, 256);
plot(xcorr(n,n))
