The function “fft” is applied to an entire signal and hence cannot be used on signal data as it comes. Instead, you can use the short-time fft “sfft” function on a signal of known length, after windowing the data
The "fft" function is logically applied to an entire signal, but you do not have an entire signal available in most real-time applications. Instead, you can use short time Fourier transform, "stft" on a non-stationary signal that changes over time. The “stft” of a signal is calculated by sliding an analysis window of fixed length over the signal and calculating the discrete Fourier transform of the windowed data.
You can use windowing and “stft” function because the windowing effectively cuts out the influence of events older than a certain time, then the implication is that you can process in real time by keeping a moving buffer. For example you might need to keep (say) the last 128 samples of the previous buffer, and put the current buffer at the end, and process.
You can use the buffer from the Audio System Toolbox or the DSP Toolbox and use an appropriate system object. Then you can step() the object to get the next buffer full.
I hope the above information helps you.
Thanks,
Keerthana