Help interpreting Fast Fourier Transform.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Snow
am 28 Jun. 2023
Verschoben: Star Strider
am 28 Jun. 2023
I followed this video : https://www.youtube.com/watch?v=cw9eoSzln_k&ab_channel=Study%26Tutor
to perform a FFT on data I collected that reperesented voltage vs time. The data can be found here https://mega.nz/file/JX81BI5L#ivW7WgkKpxjhqMBXC2nUYuc8ykC_sXahZuAu1UaMc6w
The code I used is as follows :
t = readmatrix('fftpoop.xlsx');
>> dt = 16.788
dt = 16.7880
>> fs = 1/dt;
>> plot(t(1:16789,2))
>> %time
>> t = t(1:16789,2);
>> t_f = fft(t);
>> m = length(t_f);
>> freq = (-m/2:(m/2-1))*fs/(m-1);
>> plot(freq,fftshift(abs(t_f)))
And i recieved a plot that looks like this :
I manually counted the average time between peaks from the original time data to be .37s. I used this time to calculate the a distance, D = 8.3*10^-7 m/s * .37 s = 307 nm* (2) = 614 nm. This is very close to the value I was expecting (633 nm).
I believe that If I find the frequency from this fft that has the highest peak, then I can use that to use the equation, time = 2pi/freq and verify my time is correct / make my time variable more accurate, and get a better value for D calculated above
I tried using the x value centered at 0 and the next highest peak from the 0 peak in the above graph as my frequency, but they all produce numbers wayyyy bigger from the expected distance.
Am I using this data correctly?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 28 Jun. 2023
Verschoben: Star Strider
am 28 Jun. 2023
My analysis —
M1 = readmatrix('fftpoop')
t = M1(:,1);
s = M1(:,2);
L = size(M1,1)
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
figure
plot(t, s)
grid
xlabel('Time (s)')
ylabel('Amplitude (V)')
NFFT = 2^nextpow2(L)
FTs = fft((s-mean(s)).*hann(L), NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
[pks,locs] = findpeaks(abs(FTs(Iv))*2, 'MinPeakProminence',0.015);
time = 1/Fv(locs)
figure
plot(Fv, abs(FTs(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Magnitude (V)')
xlim([0 20])
ylim([min(ylim) 0.022])
text(Fv(locs), pks, sprintf('\\leftarrow %.3f Hz\n %.3f V', Fv(locs), pks), 'Horiz','left', 'Vert','top')
I assume your ‘time’ is based on radian frequencies, so I calculated it as the period of the peak frequency in Hz (since my plot is in Hz), giving the period in seconds. I am not certain what the data are or what your analysis requires, so I will defer to you for those.
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Discrete Fourier and Cosine Transforms 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!