help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [help] FFT & Spectrogram


From: Judd Storrs
Subject: Re: [help] FFT & Spectrogram
Date: Thu, 2 Jul 2009 12:26:36 -0400

On Thu, Jul 2, 2009 at 4:56 AM, febty febriani <address@hidden> wrote:

###
octave <<EOF
Fs=1;   
n=4096;                       
fh=fopen("result.dat","r");
y=fscanf(fh,"%lf");
window=hanning(n);                   
y1=(y(1:n)).*(window);                   
y2=fft(y1,n*2);   
[S, f, t] = specgram(y, n, Fs, window, length(window)/2);                   
S=abs(y2(1:n));
S=S/max(max(S));                   
x=((1:n)/n)*(Fs/2);                                           
subplot(2,1,1);plot(x,S);axis([0 0.01]);title("200901");xlabel("Frequency");ylabel("Amplitude");
subplot(2,1,2);imagesc(flipud(20*log10(S)));
print -dpng output.png;
drawnow;
sleep(10);
EOF
###

I'm not familiar with specgram() but I suspect S is a vector, i.e. 1xN or Nx1 so the imagesc command complains because S isn't an MxN matrix with both N>1 and M>1 (i.e. it's a vector not an image(=matrix)).

You can try adding a disp(size(S)) right before the imagesc call to verify the dimensions.

If you want to display S as an image anyway, I might work to duplicate S to create a 2xN or Nx2 matrix. i.e. something like

S = repmat(S,[1,2]); # if S is Nx1
S = repmat(S,[2,1]); # if S is 1xN

--judd



reply via email to

[Prev in Thread] Current Thread [Next in Thread]