How to plot FFT of time domain data?
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nelson
el 16 de Sept. de 2014
Respondida: pilot 88
el 18 de Mzo. de 2016
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 comentarios
Respuesta aceptada
Star Strider
el 16 de Sept. de 2014
Editada: Star Strider
el 16 de Sept. de 2014
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 comentarios
Star Strider
el 8 de Oct. de 2014
Editada: Star Strider
el 8 de Oct. de 2014
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
Más respuestas (2)
Geoff Hayes
el 16 de Sept. de 2014
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 comentarios
pilot 88
el 18 de Mzo. de 2016
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 comentarios
Ver también
Categorías
Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!