Plot a Function with Sum

Hi all,
I have to plot this simple rectangular curve.

NN = 100; tlc = 2*Pi/36; NI = 1000; r3 = 40*10^(-3);
an2[n_] := 
 NI*(1 - Exp[I*n*Pi])*(Exp[I*n*tlc*(1/2)] - Exp[-I*n*tlc*(1/2)])/(tlc*
     r3*(2*I)*n*Pi)
Plot[
 Evaluate[Sum[an2[n]*Exp[-I*n*theta], {n, -NN, -1, 1}] + 
   Sum[an2[n]*Exp[-I*n*theta], {n, 1, NN, 1}]], {theta, 0, 2*Pi}]

I do not get a rectangular signal but another one.
Can any one help
Thank you

The answers are only for difficult questions !?

Hi,

I wanted to help, but do not understand what your problem is. The explanation in your post is rather short. You say something about a rectangular signal, but then you show some code, and the result is not unexpected for me. So I am to really sure what it is you want and why you think there is a problem and what you have tried. It would also help to have some figures in the post.

Do you want something like this (modified from Mathworld):

(series = Rest[FoldList[Plus, 0, Table[Sin[n Pi x]/n, {n, 1, 9, 2}]]] 4/Pi) // ColumnForm // TraditionalForm

and

Plot[Evaluate[{
   2 UnitStep[x] - 2 UnitStep[x - 1] + 2 UnitStep[x - 2] - 1,
   Sequence @@ series
   }], {x, -.02, 2.02},
 PlotStyle -> {Thickness[.01], Red, Yellow, Green, Blue, Orange},
 PlotRange -> All, AxesLabel -> TraditionalForm /@ {x, f[x]}]

It would help if you were to state your problem more clearly. Some more background will help you to get more answers.

Cheers,

Marco

Thank you for your answer.
In the attached file, you can find the code.
I want to plot this Fourier series expansion of a periodic rectangular signal (with plot like in the commands I do). I do not know why I can not obtain my signal.
I do it with an other softwar and I attached the curve in the attached code.
Thank you again.

Hi Boughrara,

you are plotting a function which is complex valued, so I was wondering why one sees a plot at all! Anyway, I think all you need to do is to make sure you see your complete plot; for this you need to plot it like so:

Plot[ ... you function ..., {n,1, NN}, PlotRange -> All]

Regards – Henrik

Dear Henrik,
Thank you, now the plot is nice.
Best regards
Kamel