0
$\begingroup$

How does one plot $y=|x|$ in MATLAB?

  • 0
    I have rolled back the edit on this question to the original, and added the OP's updated question regarding $y=|x|$ to the post in order to maintain a sense of context and continuity with the question the OP is asking, as the disjunction of the two has led to some apparent confusion. @Albert if your original question is no longer relevant, feel free to comment, answer your own question, or edit the post as such.2012-10-16

1 Answers 1

1

What does gibbs/fourier have to do with absolute value? Are you supposed to get its fourier expansion and then plot it against the absolute value function? Because that will exhibit gibbs phenomenon.

If you just want to plot y=abs(x), then just do

x = -10:0.01:10; y = abs(x); plot(x,y)

If you need the fourier expansion, MATLAB is not the way to do it. I would do it by hand analytically or use some symbolic software like MATHEMATICA. But if you use mathematica, then might as well plot in it too. It's easier and you get prettier pictures too.

  • 0
    If you let $f(x) = |x|$ on $[-10,10]$ and be $20$-periodic, $f$ will be continuous, and I don't think it will exhibit the Gibbs phenomenon.2012-10-19