How to find the noisy signal using fourier transform for this data?

33 views (last 30 days)
I was given the values M3 and t and told to analyze the noisy signal for every 5Hz, please check attached the values.

Answers (1)

Scott MacKenzie
Scott MacKenzie on 14 Jul 2021
Edited: Scott MacKenzie on 14 Jul 2021
Here's what I put together. The input signal is somewhat noisy, but it is also periodic @ 34.4 Hz.
f = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/684143/SPEED%20SENSOR.xlsx';
A = readmatrix(f);
t = A(:,2);
y = A(:,1); % M3 sensor values
n = length(y);
% remove NANs
nanLogical = isnan(t) | isnan(y);
t(nanLogical) = [];
y(nanLogical) = [];
% recale signal to +/- 1
y = rescale(y, -1, 1);
% determine sampling interval and rate
sInterval = mean(diff(t));
sRate = 1 / sInterval;
% perform fast fourier transform
Y = fft(y);
% get frequency spectrum
P2 = abs(Y/n);
P1 = P2(1:n/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = sRate*(0:(n/2))/n;
% plot signal and frequency spectrum
tiledlayout('flow');
nexttile;
plot(y(1:500)); % first 500 samples only (so wavefrom is visible)
title('Signal');
nexttile;
plot(f,P1);
title('Frequency Spectrum');
  6 Comments
Scott MacKenzie
Scott MacKenzie on 16 Jul 2021
Edited: Scott MacKenzie on 16 Jul 2021
The two plots actually contain the same information but with a different perspective.
The top plot is a "time domain" plot, with the x-axis representing time and y-axis representing the amplitude of the signal at each time point. To improve the look of the plot, I only plotted the 1st 500 samples. There are actually 70,000+ samples in total.
The bottom plot is a "frequency domain" plot of the same signal. The sampling frequency for your sensor was 100 Hz, so the x-axis of this plot goes from 0 to half this, or 50 Hz. The y-axis is the amplitude of the signal at each frequency. You can see some noise along the bottom, but there is a big spike at 34.4 Hz. This means the signal includes a periodic waveform at that frequency.
As for the code generating the frequency spectrum plot, it's mostly just copied from the examples in the documentation for the fft function. Have look there if you want the play-by-play details.
BTW, what is your sensor measuring?
Hiril Patel
Hiril Patel on 26 Aug 2022
I hope I am not too late here,
Can you tell me how do I find noise if I don't have the time stamps of the data? I only have recorded data from the sensor but the signal is noisy and now I discovered that I need time stamps to use FFT is there any work around for that?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!