How to find peak value using FFT
1 view (last 30 days)
Show older comments
Hello,
My question is how to find the time-domain peak value (magnitude) of a signal in frequency domain.
So far, I have applied FFT to a collection of sampled data in the attached CSV file. The collected data has the following information:
- signal length is 30 seconds
- signal was sampled at 1kHz
- signal contains the magnitude of almost 0.14 amps @15.8 Hz and 0.12 amps @16 Hz according to the attached image in time domain
Could anyone advise how to locate the above peaks with its corresponding frequencies in frequency domain?
The following is the code that I did so far:
filename = 'FFT_Case_1.4_A.csv';
signal = csvread(filename);
N = length(signal); % defines the total number of signal array
fax_bins = [0:N-1]; % fix the x-axis with the starting point of 0
half_N = ceil(N/2); % get the half number of samples for single side plot
fs = 1000; % sampling frequency of signal
fnyquist = fs/2; % Nyquist frequency of signal
signal_mag = 2*abs(fft(signal)/N); % magnitude of signals after transform
fax_Hz = fax_bins*fs/N; % convert bins to Hz using simple formula
plot(fax_Hz(1:half_N), signal_mag(1:half_N))
xlim([1 51])
title('Single-side Magnitude Spectrum')
xlabel('Frequency (Hz)')
ylabel('Magnitude (Amps)');
Any advice is most appreciated. Thanks.
Kind regards, Thomas
0 Comments
Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!