0
$\begingroup$

I am a beginner so please excuse some of my ignorance, I am still very much learning.

My original signal comes from a DC sensor that was measuring the distance of a pulsating object. The sensor was on top of a vibrating machine. I am trying to find the frequency of the vibration of the machine and the pulsating object.

I want to know the frequencies and then I want to reduce the noise by filtering both.

Towards that end: I imported the data in GNU Octave and performed FFT. I noticed a large spike at 0Hz. Upon further reading I found that this can be due to "DC offset bias."

I subtracted the mean of my measurement to remove this bias. Now when I perform FFT I get nonsense.

enter image description here

GNU Octave Code:

DATA = file(8:end,2)

DATA_minus_avg = DATA.-mean(DATA)

subplot(4,1,1)
plot(DATA)
title('Original Data')
subplot(4,1,2)

plot(fft(DATA))
title('FFT of Original Data')
subplot(4,1,3)

plot(DATA_minus_avg)
title('Original Data minus Average')
subplot(4,1,4)

plot(fft(DATA_minus_avg))
title('FFT of Original Data minus Average')

The original data:

267.24
267.66
267.27
267.27
267.29
267.3
269.47
267.29
267.35
268.42
267.32
268.1
267.42
267.31
267.34
267.68
267.32
267.35
268.74
267.68
267.82
267.32
268.23
268.77
267.33
267.33
267.32
267.35
267.35
267.33
268.77
267.7
267.33
267.65
264.64
267.43
267.34
268.35
267.74
267.33
267.38
267.34
268.05
267.32
268.03
268.43
267.33
268.8
267.35
267.33
268.4
267.62
268.51
267.33
268.09
270.26
267.32
268.25
267.35
267.88
267.33
267.33
267.85
267.35
269.43
267.35
269.5
269.1
267.99
268.77
267.35
268.8
268.79
267.34
268.71
267.34
268.8
268.76
267.36
268.44
267.33
268.13
267.66
268.78
268.02
267.36
268.31
267.35
268.45
268.38
267.71
268.78
268.01
269.13
267.31
266.32
268.5
267.32
269.32
267.35
268.46
268.04
266.59
268.45
267.48
$\endgroup$

1 Answer 1

2
$\begingroup$

The output of the Fourier transform is complex. You are likely wanting to plot the magnitude of the transform, which can be found by instead plotting abs(fft(DATA)). Similarly, if you are interested in the phase information of the transform, that can be found with angle(fft(DATA)) (in MATLAB, at least).

Also, be aware that fft will output a spectrum beginning at 0 Hz and going to $f_s/2$ (where $f_s$ is the sample rate of the data) and back to almost 0 Hz through negative frequencies. To adjust for this, further adjust your code to abs(fftshift(fft(DATA))) and your associated frequencies will be f = ((N/2):((N-1)/2))*fs/N for an even input data and f = (((N-1)/2):((N-1)/2))*fs/N for an odd input data length.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.