RegionMember
work for Interval
.
RegionMember
work forInterval
.
f = Piecewise[{{1, RegionMember[Interval[{0, 1}]]@{x}}}, 0];
g = Piecewise[{{1, 0 < x < 1}}, 0];
Plot[{f, g}, {x, 0, 2},
PlotStyle -> {Directive[Red, Opacity[.2], AbsoluteThickness[10]],
Blue}]
When we want to use Element
, we need to write such as Element[{1/2}, Interval[{0, 1}]]
(*True *)
.
- When we want to use
Element
, we need to write such asElement[{1/2}, Interval[{0, 1}]]
(*True *)
.
h = Piecewise[{{1, Element[{x}, Interval[{0, 1}]]}}, 0];
Plot[h, {x, 0, 2}]