|
Hi All, I had the below code to analyze the sound audio. However, i kept receiving the below error.
??? Error using ==> fft
Out of memory.
Can anyone advise?
Tks
[x,fs]=wavread('AVB.wav');
y=x(:,1);
Y = fft(y);
subplot(312)
plot(abs(Y));
xlabel('Frequency(Hz)');
ylabel('Magnitude');
axis([0 length(Y)/2, 0 max(abs(Y))]);
[nSamples,nChannels]=size(y);
waveFileLength=nSamples/fs;
N = 2^(nextpow2(length(y(:,1))));
Py=fft(y(:,1),N);
NumUniquePts = ceil((N+1)/2);
Py = Py(1:NumUniquePts);
Py = abs(Py);
Py = Py/length(y(:,1));
Py = Py.^2;
Py = Py*2;
Py(1) = Py(1)/2;
if ~rem(N,2)
Py(end) = Py(end)/2;
end
f = (0:NumUniquePts-1)*fs/N;
subplot(313)
plot(f,Py);
title(sprintf('Power Spectrum of wav file. Length=%3.1f sec, Fs=%d Sample/sec',waveFileLength, fs));
xlabel('Frequency(Hz)');
ylabel('Power');
|