1
$\begingroup$

I have been trying to use Manipulate in the following expression :

Manipulate[
  Plot[
    Evaluate[
      FourierSeries[
        Piecewise[{
          {0, x < 0}, {1, (0 <= x <= 1)},
          {0, 1 < x }
        }], x, y
      ]
    ], {x, -2, +3}
  ], 
  {y, 1, 15}
]

When I press "evaluate notebook" it gives the y=1 plot, but moving the slider creates a blank plot.

Any help would be greatly appreciated.

$\endgroup$

1 Answer 1

1
$\begingroup$

What you call y is n as in the nth order Fourier series. If you don't use a step size, then the command fails. Actually, your code works. Try open the value box for y on the manipulate and enter 2 or another integer in range instead of dragging the slider.


Or specify an integer step as follows:

Manipulate[
 Plot[Evaluate[
   FourierSeries[
    Piecewise[{{0, x < 0}, {1, (0 <= x <= 1)}, {0, 1 < x}}], x, 
    y]], {x, -2, +3}], {y, 1, 15, 1}]
$\endgroup$
1
  • $\begingroup$ Thanks for the accept. I have added the explanation to the answer. $\endgroup$
    – Syed
    Commented Aug 14, 2023 at 12:49

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.