# Implementing FFT in Matlab I am facing a trouble implementing the fft and appreciate your advice. My data structured as follow: The data are retrieved from the share market for one day change in the share price. The time range from (11:00:00 to 15:00:00) this means 16200 Sec. In matlab its represented as serial so it will be from 0.4584 to 0.6458. Data are not sampled in fixed freqency. Price is sampled only when there is a change in price. For example ( it can be sampled in each second and sometimes in 30 Seconds interval). • What you're asking for is the DFT of a non-uniformly sampled signal. I suggest you change the title of the question accordingly. The votes to close this question are presumably because of the words 'implement' and 'Matlab'. You should rather ask questions about signal processing in general. – Deve Sep 29 '13 at 11:10

## 2 Answers

For calculating the frequency spectrum of an non-uniformly sampled signal I see two options:

• Interpolate the data in order to obtain evenly spaced samples before taking the FFT as suggested by Hasan. Use the Matlab function interp1. If you have the Data Analysis toolbox, the resample function of the timeseries class might be worth a look.
• Use the Lomb–Scargle periodogram. There's no builtin Matlab function but an implementation from Matlab File Exchange exists.
• If you interpolate or add zeros then you are changing the data Anyway I have tried different kind for data which are sampled each day and run for a year. I always getting a symmetric fftshifted or the FFT have a spicke on zero. I will attach the signal and the FFT on my post. Can you comment please ? – omo tam Oct 5 '13 at 10:43
• Interpolation means "making data up", that's true. If you think it will bias your data, then probably the Scargle perodogram is for you. The question in your comment sounds like a new question. You should therefore aks a new question, I will not discuss it in the comments. – Deve Oct 5 '13 at 12:51

You can write an algorithm that fills the time gaps with the fixed price. Now you have the price/second. I can't see issues with taking the FFT of this new time series (1:16200).

• it doesnt make sense to fill the gaps. What would be my bin and my frequency range ? – omo tam Sep 28 '13 at 17:23