# How to calculate STFT of a function for a rectangular window

How to calculate the STFT (by hand) of $$u(n)\cos(0.2\pi n)$$ for a rectangular window of a length 20, positioned at $$n = 5$$.

I know that to use STFT I need to divide longer signal to a shorter parts and than calculate Fourier Transform on each part. Also doing it from the definition is very long and I assume that there is a more efficient way to do it on paper.

I don't know how to start with the question so any materials on this topic are appreciated.

I came up with this idea:

First picture is just a rectangular window of length 20 and position 5. Second picture is how I see the STFT of it. Now to calculate STFT should I provide some coefficients like mainlobe width and highest sidelobe? How I can calculate them from my data?

Are my pictures good? • Added possible first step. (Don't know if it is correct) – sswwqqaa Nov 18 '18 at 20:56

I don't understand what you mean by "positioned at $$n=5$$" with length $$20$$. Indeed:
If I interpret your question in its most obvious sense, the window starts from $$n=5$$ to $$n=20+5-1=24$$, on an interval where $$u[n]=1$$, so you'd just have to compute a simple DFT of a cosine. The result can be obtained via Euler/De Moivre formulae, with two finite sums of geometric series.