1

I'm trying to input a .wav file by

    filename = 'C:\Users\kiit\Desktop\New folder\file.wav';
    [y, Fs, nbits] = wavread(filename)

after that I'm calculate the length by-

L=length(y)

I've performed hamming window by-

w=window(@hamming,L);

when I perform fft by

F=fft(y,w)

It's showing warning as Warning: FFT length must be a non-negative integer scalar.

F =

Empty matrix: 0-by-1

Any help??

chappjc
  • 30,359
  • 6
  • 75
  • 132
Misha
  • 685
  • 8
  • 20

1 Answers1

2

Your fft command is wrong. The second argument is the FFT length, not the window.

Y = fft(X,n) returns the n-point DFT. fft(X) is equivalent to fft(X, n) where n 
is the size of X in the first nonsingleton dimension. If the length of X is less 
than n, X is padded with trailing zeros to length n. If the length of X is 
greater than n, the sequence X is truncated. When X is a matrix, the length of
the columns are adjusted in the same manner.

To window, you apply (elementwise multiply) in the time domain (i.e. y.*w).

And to understand the output of fft:

Community
  • 1
  • 1
chappjc
  • 30,359
  • 6
  • 75
  • 132
  • I get it but I'm having problem in your last statement do you mean to say that I'm, doing hamming window wrong or in fft command should I use(y.w*) – Misha Oct 03 '13 at 05:39
  • 1
    Window the signal first (`y_w = y.*w;`), then do the FFT (`F = fft(y_w);`. – chappjc Oct 03 '13 at 05:43
  • I did what you told me to. It's showing a star kinda formation and I don't think this is what I want. – Misha Oct 03 '13 at 05:51
  • I think you got it. What commands are you using to display the result? – chappjc Oct 03 '13 at 05:57
  • I'm sorry for late reply and I'm using plot(F) – Misha Oct 03 '13 at 06:21
  • when I use this command F=fft(y_w); it displays nothing. then to see waveform I plot it using plot(F). I do know about output produced by fft What I'm unaware is the waveform. how should it look like?? or am I doing it right and thank you so much – Misha Oct 03 '13 at 10:34
  • Did you see the links I added? `fft` does not display anything. The Fourier transform is a frequency space, with frequency on the x axis with magnitude and phase (obtained by abs and angle) on the y axis. Please read the links. I'm pretty sure that more than answers your question. I hope you manage to learn the meaning of the FFT. – chappjc Oct 03 '13 at 17:10