How can i create a FFT/FRF graph using matlab from csv file?
16 views (last 30 days)
Show older comments
as the title, i want to convert the data to the frequency domain using FFT... and here the csv....which function should i use? tfestimate or fft to generate FRF in order to get the natural frequency....
0 Comments
Accepted Answer
KSSV
on 14 Mar 2017
clc;
data = csvread('data.csv') ;
t = data(:,1) ;
amp = data(:,2) ;
L = length(t) ;
dt = max(diff(t)) ;
Fs = 1/dt ;
Y = fft(amp);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
% xlim([0 3000])
3 Comments
Mobeen Sohail
on 30 Apr 2018
in this code why we used p1(2:end-1)=2*p1(2:end-1). unless in ploting we only used p1 value??
More Answers (1)
Piash Das
on 11 Apr 2017
Hi, I am having problem to generate FFT from time-domain data of csv file. I can generate values of two variables from the two rows. The first row contains time and the second row contains current. Now I can generate a normal plot. But I want to plot FFT and power spectral density. I got the csv from a simulation (Cadence). there is no fixed step-size of the time values which is problem. Can anyone help me generating FFT and psd? I have attached the file for your convenience.
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering 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!