Overlapping with flat-top window MATLAB I am applying a flat-top window to signal because I am very interested in its actual amplitude in the time-domain. I have read that overlapping will improve results. I am using MATLAB and the following is the code that I am using to compute FFT with flat-top window:

time = 0:0.1:500;  
data = 1.8*sin(2*pi*0.2003*time);Fs = 10;  
N = length(data);  
w = flattopwin(N);  
wdata = data(:).*w;  
ws = sum(w);  
Y = fft(wdata)/ws;  
freq = 0:Fs/N:Fs/2-Fs/N;  
freq = freq';  
amplitude = 2*abs(Y(1:floor(N/2)));  
plot(freq,amplitude);


Can someone please help me to modify the code so that I can include overlapping? I am relatively new in this field and am still confused. Thanks.
Higher size of your FFT best the resolution of frequencies, but of course it has a cost resulting in a longer to process !

To apply overlap you need define one window size to analyse and one hop/step to walk around your data!

This picture illustrates how this works:



Here a simple code using Window size = 2048pts and 50% overlap step!

n_samples = length(yourdata);
winSize = 2048;

%50% overlap or 0 to not use overlap
OverlapStep = 50;

if OverlapStep &gt; 0

    Overlap = floor((OverlapStep*winSize) / 100); 
    nFrames=floor(n_samples/Overlap)-1; 
else
    Overlap= winSize;
    nFrames=floor(n_samples/Overlap)-1;
end


k=1;
while ( (k+winSize-1) &lt;= n_samples )

    FrameSignal = yourdata(k:k+winSize-1);

    %%%%%%%%%% Start process FFT here  %%%%%%%%%%%%%%%%%
    w = flattopwin(winSize);  
    wdata = FrameSignal(:).*w;
    Y = fft(wdata)
    .
    .
    .

   k=k+Overlap;
end