Analysis with Window before FFT

I have two signals $x$ (see below) and $k$ (obtained by giving circular shift of 106.5849 in $x$). Before I take FFT of both ($x$ and $k$) I want to do window analysis on them.

After applying FFT I will find Cross power spectrum of both $f$ domain signals.

t=0*10^-9:4*10^-9:150*10^-9;
fc=5*10^6;
xi=sin(2*pi*fc*t);
yi=154*10^-9:4*10^-9:2000*10^-9;
y=yi*0;
x=[xi y];
k=fshift(x,106.5849);

My eventual aim is to implement the following diagram.

• It is not easy to understand your question. What do you mean by window analysis? Do you understand why windows are used? – Moti Oct 2 '15 at 1:26
• @Moti Well,as far as I know window is used in filter design and to see the spectral analysis.But in my case (see above) I am unable to understand what size I should choose for window.My goal is to find the delay between two signals using the algorithm shown in figure.Can you please help on it.Thanks in advance! – Haider Oct 2 '15 at 7:28
• @Haider: There's no such thing as "window analysis". The block diagram implies your multiplying signal samples by a "window" sequence (such as hanning, or Hamming). Is that what you're doing? A common misconception among DSP beginners is that you must window a signal sequence ANYTIME you intend to perform an FFT. This is incorrect. Windowing a signal prior to performing an FFT is ONLY needed for very specific spectrum analysis applications. You need to know the spectral effects of windowing and decide if windowing is appropriate to your application. – Richard Lyons Oct 2 '15 at 10:10
• @RichardLyons Thanks fro your comment.As I mentioned I am trying to find delay between two signals using this method (block diagram).I am getting high error so I am not sure where i m doing mistake .Can you extend my code (given above) w.r.t bloc diagram please.Would be so nice.You can signal x as from sensor1 and k as signal from sensor2.please – Haider Oct 2 '15 at 10:17
• @Haider Window before an FFT shape the frequency bins and the leakage into other bins (side lobs) that result from the use of a limited time series of samples to analyze an infinite signal. I assume that by "analysis with...." you mean applying a window. What exactly you mean by "cross power spectrum"? Implementing cross multiplication of power? Running an FFT to create the spectrum of the power? - What is the exact mathematical function? If this is a narrow band signal, why not doing the detection in the frequency domain? Do you try to analyze a signal multiplied by itself time shifted? – Moti Oct 3 '15 at 15:43