How to plot FFT of time domain data?
18 次查看(过去 30 天)
显示 更早的评论
Dear all...
I have vibration data from Digital Storage Oscilloscope (DSO), the extension is 'xxx.CSV' . I need to convert it into Freq Domain (Magnitude vs Freq). I've tried several times and still stuck, I can't import that data into the formula/function. I've attached an excel file I got from the DSO (only 75KB), maybe you can download and see the excel files for complete information (like sample rate, length of signal,sample interval, etc). Ignore the CH2 (Impulse Hammer input) for a while, I only need the FFT from CH1 and plot it.. Can you guys help and suggest me, what function/formula should I write?
Thanks in advance
Regards
0 个评论
采纳的回答
Star Strider
2014-9-16
编辑:Star Strider
2014-9-16
Guessing here as to what channel your data are in, but this seems to work:
[D, T, R] = xlsread('ADS00001.CSV');
F = D(:,4); % Data Channel
Ts = 2E-4; % Sampling Interval (s)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency
F(isnan(F))=[]; % Eliminate ‘NaN’ Values First
LF = size(F,1); % Length of Data Vector
T = linspace(0,1,LF)*Ts; % Create Time Vector
figure(1) % Plot Data
plot(T, F)
grid
FF = fft(F)/LF; % Fourier Series of Data, Freq Vector
Fv = linspace(0,1,fix(LF/2)+1)*Fn;
Iv = 1:length(Fv); % Index Vector
figure(2) % Plot FFT
plot(Fv, abs(FF(Iv)))
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
axis([0 1500 ylim])
6 个评论
Star Strider
2014-10-8
编辑:Star Strider
2014-10-8
My pleasure!
[A,L] = findpeaks(abs(FF(Iv)),'MinPeakDistance',10, 'MinPeakHeight',5E-4); % A = Amplitude
F = Fv(L); % F = Frequency
The first two it finds seem to be spurious, so you can manually delete them by simply taking A(3:end) and F(3:end).
This gives you (with a couple fprintf statements):
Frequency (Hz) Amplitude
76.667 5.80261E-03
110.000 1.38142E-03
221.667 8.47767E-04
更多回答(2 个)
Geoff Hayes
2014-9-16
Nelson - it may be helpful to include what you have tried so that others can see what the problem may be and offer advice.
For importing the data from the csv file, consider using importdata. This will allow you to separate the header lines (of which you have ten) from the rest of the numeric data
myData = importdata('ADS00001.csv',',',10);
myData will be a structure; the numeric data (a 2992x6 matrix) will be in the field data. This matrix has three empty columns (the first three) followed by (presumably) the time stamp for each sample, the CH1 data, and the CH2 data
timestampsSec = myData.data(:,4); % in seconds
ch1Data = myData.data(:,5); % volts?
From timestampsSec we observe that the sample rate, Fs, is 1/2e-05 or 50000 samples per second. However there is only about 3/10 of a second's worth of valid data (the first 3/10 correspond to negative timestamps and the ch1 data is near zero - you will see this when you plot the data, time vs ch1).
See fft for examples on how you would transform ch1Data from the time domain to the frequency domain, and plot the result.
0 个评论
pilot 88
2016-3-18
Dear all,
How can I do FFT from my excel data - this accelerometer data from vibration test. The
FS = 500 Hz
First column = time
Second column is acceleration (m/s^2).
Data is as attached.
Thank you very much.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!