From: Jon on
Does anyone have any ideas on making the following code faster?

offset = [1:step:length(x)-win_size];

S = zeros (n, length(offset));

for i=1:length(offset)

S(1:win_size, i) = x(offset(i):offset(i)+win_size-1) .* window;
end

I'm running through sections of long high sample rate wave files (250khz) so each x vector that comes through to the spectrogram is 12500 samples. The problem here is that profiler says "S(1:win_size, i) = x(offset(i):offset(i)+win_size-1) .* window;" takes 3 times longer than the fft itself which is done on S.