Hi Avan,
I wish you had provided more information about your problem.
I don't see any sign of fft in your code?! I don't really know what's your intention.
But if you just want to make a fft plot of your data, which apparently is x you may use this code I created to facilitate using fft.
It's very simple to use fft, just take a look inside the file and you'll understand how it's done.
All you need is the data and sampling frequency which is defined a Fs I believe.
I'm hoping this helps but let us know if your problem is not solved.
Good Luck