MATLAB: How to plot the fft of a pressure data

.csv filedatafftplotpressure

Hello. I have a question to all. I really want to know to plot fft my pressure data. So, I tried to do FFT, but it didn`t go well. If there is someone can catch mistake, then please may I get some advise? I attached my file!
[fname,pathname] = uigetfile('.csv','Select CSV File to Load, Plot, Compute RMS & FFT');
disp([pathname fname])
data = csvread([pathname fname]);
[N,m] = size(data);
t = data(:,1); %time in seconds
x = data(:,2); %array of data
Fs = 1/(t(2)-t(1));
figure(1)
plot(t,x)
xlabel('Time (s)');
ylabel('Pressure');
title(chamber pressure);
grid on;
freq = 0:Fs/length(x):Fs/2; %frequency array for FFT
xdft = fft(x); %Compute FFT
xdft = 1/length(x).*xdft; %Normalize
xdft(2:end-1) = 2*xdft(2:end-1);
figure(3)
plot(freq,abs(xdft(1:floor(N/2)+1)))
xlabel('Frequency (Hz)');
ylabel('Fourier spectrum');
title(['FFT' chamber pressure]);
grid on;

Best Answer

I continue to recommend the R2015a documentation for fft (link). Specifically not the code between the first (top) two plot figures.