is the FFT right?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Raidah Zaman
am 3 Mai 2021
Beantwortet: Star Strider
am 3 Mai 2021
I am trying to analyze data that I recorded from the Force Sensitive Resistors (FSRs) coded on Arduino through data streamer on excel. I used four FSRs, so there are 4 columns of data over a set of time (1200 rows, about 15 seconds). I seperated time from the FSR data so that I can graph the FFT of the FSR data against the time.
I have made a different question which has been answered, but I was wondering if this method works as well.
Here is the code:
X = importdata('botdata.csv');
t = importdata('botdatatime.csv');
subplot(2,1,1);
plot(t,X);
xft=fft(X,[],1);
xabs = abs(xft);
subplot(2,1,2);
plot(t,xabs);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/606450/image.jpeg)
This is what was displayed.
Now I don't know if it makes sense or not.
What is the meaning of the y axis?
Is this correct?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 3 Mai 2021
‘What is the meaning of the y axis?’
It is necessary to normalise the fft result by the length of the vector it uses as an argument. (This is nin the fft documentation.) Once that is done, the y-axis units make sense.
‘Is this correct?’
Almost. I made a few changes to eliminate the constant offset from the fft result, normalise it, and plot a one-sided Fourier transform. The multiplication-by-2 corrects the one-sided Fourier transform amplitude, since the energy at each frequency is divided evenly betweek the ‘positive’ and ‘negativeÄ fft frequencies.
X = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/606440/botdata.csv');
t = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/606445/botdatatime.csv');
subplot(2,1,1);
plot(t,X);
grid
xlabel('Time')
ylabel('Amplitude')
L = numel(X);
Ts = mean(diff(t))
% Tsd = std(mean(diff(t)))
Fs = 1/Ts;
Fn = Fs/2
xft=fft(X-mean(X),[],1)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
xabs = abs(xft);
subplot(2,1,2);
plot(Fv,mag2db(xabs(Iv)*2))
grid
ylim([-75 50])
xlabel('Freqency [units]')
ylabel('Power [dB]')
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spectral Measurements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!