MATLAB: How can i create a FFT/FRF graph using matlab from csv file

frequency domainftestimatematlab fftnatural frequency

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….

Best Answer

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])