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!