That looks like it should work, although for the most accurrate results, divide ‘x_fft’ by the row size of ‘x’ or since it is a column vector, ‘L’. If ‘data_all’ has a time vector, first be certain that it is sampled regularly and consistently, and then use it to define the frequency vector to use with theFourier transfoorm plot.
.