function f = spectrum(blocks, scaling) % This function obtains a frequency spectrum % of the blocks. It does this by means of % applying an FFT to each block, and taking % the square of the complex numbers obtained. len = length(blocks); scaledlen = (len - mod(len,scaling))/scaling; n = sum(size(blocks)) - len; YS = zeros(size(blocks)); for i = 1:n YS(i,1:len)=fft(blocks(i,1:len)); YS(i,1)=0; end power = zeros(size(YS)); for i = 1:n power(i,1:scaledlen)=abs(YS(i,1:scaledlen)).^2; end nyquist = 1/scaling; freq = (1:scaledlen)/(scaledlen)*nyquist; f = power; %f = abs(YS).^2;