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?

enter image description here

  • $\begingroup$ Added possible first step. (Don't know if it is correct) $\endgroup$
    – sswwqqaa
    Commented Nov 18, 2018 at 20:56

1 Answer 1


I don't understand what you mean by "positioned at $n=5$" with length $20$. Indeed:

  • is "positioned" the beginning or the center?
  • is length an half-length around a central position, or a full length?
  • finally, at a given location, this is not an STFT anymore, but a mere windowed Fourier transform.

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.

If this is not the case, please provide more information, close forms are at hand


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.