2
votes

I am trying to get the Fast Fourier Transform of a specific part of the signal coming from a .wav file.

The .wav file is a repetition of the signal every 0.6 seconds.

I am trying to figure out how to get the repetition 10 times and compare to show that the results should be similar.

This is the code i have for now:

Fs = 44100;
cj = sqrt(-1);

[test,fs]= wavread('3b healthy2.wav'); % File data name


dt = 1/Fs;
time = 45.6;
N = time/dt;

left=test(:,1);
right=test(:,2);


I = left;
Q = right;

t = 0:dt:(time-dt);

n = length(t);

f = -Fs/2:Fs/n:Fs/2-Fs/n;

s = I+cj.*Q;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Smooth the signal
ss = smooth(s,201);

sf = fftshift(fft(ss(1:N))); % taking fft
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

figure(2)

plot(f,(abs(sf))./max(abs(sf)))

So once I separate program I can find out the time domain and from there I found that one repetition is at 45.2 to 45.8.

After I run this program I get a graph but from what I can see, it is not including one repetition but all repetitions combined up to 45.2

Edit

Below is the graph of what the signal looks like at 45 seconds. The signal is repeating continuously for 3 minutes. Now I need the FFT of that 45 seconds repetition

signal

1
I do not complete understand your question. Were you asking how to truncate the input signal for only between time 45s to 46s? If so, that shouldn't be too difficult to do.Y. Chang
yes but i need the fft of that particular times. i need to get the fftshift(fft) of multiple places and then compare them. so i am wondering where my code has an error and once i put my time to 45 is combining the fft instead of giving me the fft at 45s. hope makes sensefragkos

1 Answers

0
votes

It looks like you want to setup a window for your signal to be analyzed.

If so, in time domain you simply truncate your vector.

left=test(:,1);
right=test(:,2);
time = 45;
interval =1; // per second, for 0.1 second use interval = 0.1;
w_range = time*Fs: (time+interval)*Fs-1;
I = left(w_range) // truncate here 
Q = right(w_range) // and here
n = interval * Fs;
f = -Fs/2:Fs/n:Fs/2-Fs/n;
// continue FFT analysis ...

Make sense? Please leave comment if this not what you want.