Wolfram mathematica 在mathematica中绘制分段函数

Wolfram mathematica 在mathematica中绘制分段函数,wolfram-mathematica,Wolfram Mathematica,我想在mathematica中绘制一个分段函数。我使用了以下代码: 但结果是一片空白。哪里出错了?您需要声明变量epsilon0。目前: p[r_] := Piecewise[{{2/(\[Epsilon]0*r) + (3 r^2)/\[Epsilon]0, 0 <= r <= 1}, {4 r/\[Epsilon]0, 1 <= r <= 2}, {16/(\[Epsilon]0*r), r >= 2}}] Plot[p[r] /. \[Epsilon]0

我想在mathematica中绘制一个分段函数。我使用了以下代码:


但结果是一片空白。哪里出错了?

您需要声明变量epsilon0。目前:

p[r_] := Piecewise[{{2/(\[Epsilon]0*r) + (3 r^2)/\[Epsilon]0, 
0 <= r <= 1}, {4 r/\[Epsilon]0, 1 <= r <= 2}, {16/(\[Epsilon]0*r),
 r >= 2}}]
Plot[p[r] /. \[Epsilon]0 -> 1, {r, 0, 4}, ExclusionsStyle -> {{Red, Dashed}, Blue}]

您可以为[Epsilon]0的任何值计算函数p[r]。在1的示例中。

不知道我的第一条评论去了哪里。蓝色的东西是未定义的符号。
p[r] /. \[Epsilon]0 -> 1