# Help in 3D plot for a piecewise function?

**URL:** <https://community.wolfram.com/t/help-in-3d-plot-for-a-piecewise-function/18150>\
**Category:** Questions\
**Tags:** graphics-and-visualization\
**Created:** [May 24, 2021, 9:27pm UTC](https://community.wolfram.com/t/help-in-3d-plot-for-a-piecewise-function/18150 "2021-05-24T21:27:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubens951jti](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@rubens951jti](https://community.wolfram.com/u/rubens951jti)\
**Post date:** [May 24, 2021, 9:27pm UTC](https://community.wolfram.com/t/help-in-3d-plot-for-a-piecewise-function/18150/1 "2021-05-24T21:27:14Z")

</div>

I want to plot a piecewise function but my 3dplot doesn’t work well, someone know where is the error on my code?

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/421442b5-5293-45d4-9a36-339037f066bd)

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [May 24, 2021, 10:31pm UTC](https://community.wolfram.com/t/help-in-3d-plot-for-a-piecewise-function/18150/2 "2021-05-24T22:31:59Z")

</div>

Hi Rubens,

The predicate `x < -10 && x > 10` (and similarly for `y`) is never `True`. Perhaps you meant to use `||`?

```
V[x_, y_] := 
 Piecewise[{
  {5, x < -10 || x > 10 && y < -8 || y > 8}, 
  {0, x >= -10 || x <= 10 && y <= 8 || y >= -8}}]

Plot3D[V[x, y], {x, -15, 15}, {y, -15, 15}]

```

 ![8484plot.png](https://global.discourse-cdn.com/wolfram/original/3X/f/c/fcd01237015265192cb0119e54dfbef3cac08c57.png)

---

<div class="post-metadata">

**Author:** ![rubens951jti](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@rubens951jti](https://community.wolfram.com/u/rubens951jti)\
**Post date:** [May 24, 2021, 10:40pm UTC](https://community.wolfram.com/t/help-in-3d-plot-for-a-piecewise-function/18150/3 "2021-05-24T22:40:55Z")

</div>

Yes, that’s it! thank you
