Given the following square wave signal g(t) :
I'm trying to find the \$R(\tau)\$ of this signal, but I'm confused about how to solve the integral. In the signal above, the red square wave is the shifted signal \$g(t-\tau)\$. I understand the autocorrelation function will be periodic because g(t) is periodic, and will be a triangular waveform.
$$ R(\tau) = \int_{-T/2}^{T/2}g(t)g(t-\tau)dt $$
Trying to find the first integral for \$\tau < T/2\$ (first picture) I have: $$ R_1(\tau) = \int_{-T/4}^{-T/4+\tau} -dt + \int_{-T/4+\tau}^{T/4} dt + \int_{T/4}^{T/4+\tau} -dt + \int_{T/4+\tau}^{3T/4}dt = (-\tau) + (T/2 - \tau) + (-\tau) + (T/2 - \tau) = T - 4\tau $$
For \$T/2 < \tau < T\$ I would have the inverse I suppose since it must be symetric.
I'm confused on the first integral. I'm not exactly sure I'm correct. I think I must calculate both integrals (in the picture) on one period i.e. so that the combined integral interval for \$R_1(\tau)\$ is on one period. Or is it on a half period? In which case \$R_1(\tau)\$ would be \$ R_1(\tau) = T/2 - 2\tau\$. The fact the signal is periodic is what is confusing me. I want ultimately to get one period of \$R(\tau)\$. So my question simply is: is the expression I got for \$R_{1}(\tau)\$ correct or not?
Any help will be greatly appreciated.