Message Boards Message Boards

5 Replies
1 Total Likes
View groups...
Share this post:

Plot a Function with Sum

Posted 9 years ago

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*
 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

POSTED BY: Boughrara Kamel
5 Replies

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

POSTED BY: Boughrara Kamel

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

POSTED BY: Henrik Schachner


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


   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]}]

enter image description here

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



POSTED BY: Marco Thiel

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.

POSTED BY: Boughrara Kamel

The answers are only for difficult questions !?

POSTED BY: Boughrara Kamel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract