From: Clement Lim on 10 Sep 2009 21:54 Hi All, I am trying to plot the frequency spectrum of a mp3 file with the following code, but i kept encounting the following error: ??? Output argument "out" (and maybe others) not assigned during call to "C:\Users\User\Documents\MATLAB\mp3read.m (mp3read)". Below is my source code. Can anyone advise? Tks [filename, pathname] = uigetfile('*.*', 'Pick any file'); [Y,FS,NBITS,encoding_info,tag_info,out] = mp3read(filename); disp('Playing at the original sample rate.'); sound(y, fs); disp(fs); specgram(y); pause; Y = fft(y); plot(abs(Y)); xlabel('Frequency'); ylabel('Magnitude'); axis([0 length(Y)/2, 0 max(abs(Y))]); pause [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; plot(f,Py); title(sprintf('Power Spectrum of mp3 file. Length=%3.1f sec, Fs=%d Sample/sec',waveFileLength, fs)); xlabel('Frequency(Hz)'); ylabel('Power');
|
Pages: 1 Prev: how to read a mp3 file and analyze it. Next: Question on fsolve precision |