I'm doing some fourier transforms and I'm wondering how to plot this in Matlab to look at the graphs. I don't know how to plot the function, nor the series.

$\displaystyle f(x)=\Big\{_{ 1, \hspace{0.5cm} 0 \leq x < \pi}^{-1, \hspace{0.3cm} -\pi \leq x < 0}$; $\displaystyle f(x+2\pi)=f(x)$, for all x.

which has the fourier series (if calculated correctly):

$\displaystyle b_n=\frac{2}{n\pi}[1-(-1)^n]\to\frac{4}{\pi}\sum_{m=1}^{\infty}\frac{sin((2m-1)x)}{2m-1}$

I'd like to do a comparison of the Fourier-series and the original function by looking at the graphs. Also, how do you find the Fourier-series and their coefficients, from a function like the one I posted? It'd be great to use Matlab for that.

Any help would be appreciated