Multiple channel wav file fft

Hi.
I have a wave file, where I can hear a pump working. The file/signal has 4 channels, a Fs of 20000Hz, 16 bits and a legnth of 5212500.
Applying the fft function and ploting it afterwards, I'm able to obtain the frequency spectrum. But my question is, should I apply this procedure to the overall file/signal or to each channel? And if I must apply to each channel, could someone please explain or guide me through the task? Below there's part of my code:
[y,Fs,Nbits] = wavread('mf-363025-20111202-144058-12500-08c8'); % Read and store and audio file
t=(1:length(y))/Fs; [m d] = wavfinfo('mf-363025-20111202-144058-12500-08c8'); % File info
figure (1) plot(t,y);
figure (2) subplot (2,2,1) plot(y(1,:)) % 1st channel title ('1st channel') subplot(2,2,2) plot(y(2,:)) % 2nd channel title ('2nd channel') subplot(2,2,3) plot(y(3,:)) % 3rd channel title('3rd channel') subplot(2,2,4) plot(y(4,:)) % 4th channel title('4th channel')
L = length(y); % Length of signal NFFT = 2^nextpow2(L); % Next power of 2 from length of y Y = fft(y,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1);
figure (3) plot(f,2*abs(Y(1:NFFT/2+1)))
I've used matlab before, but it's been a while since I last used it, plus I was never an expert so I'm a litlle lost.
Thanks in advance everyone.

Respuestas (1)

Honglei Chen
Honglei Chen el 13 de Nov. de 2013

0 votos

Looks like you want to do multi-channel and each row is a channel? MATLAB's fft goes down columns by default, so you need can either do
Y = fft(y.').'
or
Y = fft(y,[],2)
HTH

2 comentarios

Ana
Ana el 14 de Nov. de 2013
Thanks for your reply.
I would say each column is a channel, y is my signal: 5212500x4.
When it plot y versus time, I obtain 4 different signals: a, b, c and d, each being:
y(:,1), y(:,2), y(:,3) and y(:,4).
Could you also explain what the lines of code you gave do exactly?
Thanks a lot for your help
Honglei Chen
Honglei Chen el 14 de Nov. de 2013
In your original post, you use y(1,:) as the first channel, so it looks like your rows are channels? Nevertheless, what you want is fft along each channel. So if the are columns, you can simply run fft(y). If they are in rows, then you can either first transpose y, do fft, and then transpose back (that's what I do in the first approach) or just do fft along rows (that's my second approach). HTH.

Iniciar sesión para comentar.

Preguntada:

Ana
el 13 de Nov. de 2013

Comentada:

el 14 de Nov. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by